本文整理汇总了Java中java.util.GregorianCalendar.AD属性的典型用法代码示例。如果您正苦于以下问题:Java GregorianCalendar.AD属性的具体用法?Java GregorianCalendar.AD怎么用?Java GregorianCalendar.AD使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.util.GregorianCalendar
的用法示例。
在下文中一共展示了GregorianCalendar.AD属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Test4149677
/**
* Reported bug is that a GregorianCalendar with a cutover of Date(Long.MAX_VALUE)
* doesn't behave as a pure Julian calendar.
* CANNOT REPRODUCE THIS BUG
*/
public void Test4149677() {
TimeZone[] zones = {TimeZone.getTimeZone("GMT"),
TimeZone.getTimeZone("PST"),
TimeZone.getTimeZone("EAT")};
for (int i = 0; i < zones.length; ++i) {
GregorianCalendar calendar = new GregorianCalendar(zones[i]);
// Make sure extreme values don't wrap around
calendar.setTime(new Date(Long.MIN_VALUE));
if (calendar.get(ERA) != GregorianCalendar.BC) {
errln("Fail: Date(Long.MIN_VALUE) has an AD year in " + zones[i]);
}
calendar.setTime(new Date(Long.MAX_VALUE));
if (calendar.get(ERA) != GregorianCalendar.AD) {
errln("Fail: Date(Long.MAX_VALUE) has a BC year in " + zones[i]);
}
calendar.setGregorianChange(new Date(Long.MAX_VALUE));
// to obtain a pure Julian calendar
boolean is100Leap = calendar.isLeapYear(100);
if (!is100Leap) {
errln("test failed with zone " + zones[i].getID());
errln(" cutover date is Date(Long.MAX_VALUE)");
errln(" isLeapYear(100) returns: " + is100Leap);
}
}
}