本文整理汇总了Java中java.time.Year.MIN_VALUE属性的典型用法代码示例。如果您正苦于以下问题:Java Year.MIN_VALUE属性的具体用法?Java Year.MIN_VALUE怎么用?Java Year.MIN_VALUE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.time.Year
的用法示例。
在下文中一共展示了Year.MIN_VALUE属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prolepticYear
@Override
public int prolepticYear(Era era, int yearOfEra) {
if (era instanceof JapaneseEra == false) {
throw new ClassCastException("Era must be JapaneseEra");
}
JapaneseEra jera = (JapaneseEra) era;
int gregorianYear = jera.getPrivateEra().getSinceDate().getYear() + yearOfEra - 1;
if (yearOfEra == 1) {
return gregorianYear;
}
if (gregorianYear >= Year.MIN_VALUE && gregorianYear <= Year.MAX_VALUE) {
LocalGregorianCalendar.Date jdate = JCAL.newCalendarDate(null);
jdate.setEra(jera.getPrivateEra()).setDate(yearOfEra, 1, 1);
if (JapaneseChronology.JCAL.validate(jdate)) {
return gregorianYear;
}
}
throw new DateTimeException("Invalid yearOfEra value");
}
示例2: provider_goodParseData
@DataProvider(name="goodParseData")
Object[][] provider_goodParseData() {
return new Object[][] {
{"0000", Year.of(0)},
{"9999", Year.of(9999)},
{"2000", Year.of(2000)},
{"+12345678", Year.of(12345678)},
{"+123456", Year.of(123456)},
{"-1234", Year.of(-1234)},
{"-12345678", Year.of(-12345678)},
{"+" + Year.MAX_VALUE, Year.of(Year.MAX_VALUE)},
{"" + Year.MIN_VALUE, Year.of(Year.MIN_VALUE)},
};
}
示例3: factory_ofInstant_minWithMinOffset
@Test
public void factory_ofInstant_minWithMinOffset() {
long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7);
int year = Year.MIN_VALUE;
long days = (year * 365L + (year / 4 - year / 100 + year / 400)) - days_0000_to_1970;
Instant instant = Instant.ofEpochSecond(days * 24L * 60L * 60L - OFFSET_MIN.getTotalSeconds());
ZonedDateTime test = ZonedDateTime.ofInstant(instant, OFFSET_MIN);
assertEquals(test.getYear(), Year.MIN_VALUE);
assertEquals(test.getMonth().getValue(), 1);
assertEquals(test.getDayOfMonth(), 1);
assertEquals(test.getOffset(), OFFSET_MIN);
assertEquals(test.getHour(), 0);
assertEquals(test.getMinute(), 0);
assertEquals(test.getSecond(), 0);
assertEquals(test.getNano(), 0);
}
示例4: factory_ofInstant_minWithMaxOffset
@Test
public void factory_ofInstant_minWithMaxOffset() {
long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7);
int year = Year.MIN_VALUE;
long days = (year * 365L + (year / 4 - year / 100 + year / 400)) - days_0000_to_1970;
Instant instant = Instant.ofEpochSecond(days * 24L * 60L * 60L - OFFSET_MAX.getTotalSeconds());
ZonedDateTime test = ZonedDateTime.ofInstant(instant, OFFSET_MAX);
assertEquals(test.getYear(), Year.MIN_VALUE);
assertEquals(test.getMonth().getValue(), 1);
assertEquals(test.getDayOfMonth(), 1);
assertEquals(test.getOffset(), OFFSET_MAX);
assertEquals(test.getHour(), 0);
assertEquals(test.getMinute(), 0);
assertEquals(test.getSecond(), 0);
assertEquals(test.getNano(), 0);
}
示例5: provider_goodParseData
@DataProvider(name="goodParseData")
Object[][] provider_goodParseData() {
return new Object[][] {
{"0000-01", YearMonth.of(0, 1)},
{"0000-12", YearMonth.of(0, 12)},
{"9999-12", YearMonth.of(9999, 12)},
{"2000-01", YearMonth.of(2000, 1)},
{"2000-02", YearMonth.of(2000, 2)},
{"2000-03", YearMonth.of(2000, 3)},
{"2000-04", YearMonth.of(2000, 4)},
{"2000-05", YearMonth.of(2000, 5)},
{"2000-06", YearMonth.of(2000, 6)},
{"2000-07", YearMonth.of(2000, 7)},
{"2000-08", YearMonth.of(2000, 8)},
{"2000-09", YearMonth.of(2000, 9)},
{"2000-10", YearMonth.of(2000, 10)},
{"2000-11", YearMonth.of(2000, 11)},
{"2000-12", YearMonth.of(2000, 12)},
{"+12345678-03", YearMonth.of(12345678, 3)},
{"+123456-03", YearMonth.of(123456, 3)},
{"0000-03", YearMonth.of(0, 3)},
{"-1234-03", YearMonth.of(-1234, 3)},
{"-12345678-03", YearMonth.of(-12345678, 3)},
{"+" + Year.MAX_VALUE + "-03", YearMonth.of(Year.MAX_VALUE, 3)},
{Year.MIN_VALUE + "-03", YearMonth.of(Year.MIN_VALUE, 3)},
};
}
示例6: factory_ofInstant_tooLow
@Test(expectedExceptions=DateTimeException.class)
public void factory_ofInstant_tooLow() {
long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7);
int year = Year.MIN_VALUE - 1;
long days = (year * 365L + (year / 4 - year / 100 + year / 400)) - days_0000_to_1970;
Instant instant = Instant.ofEpochSecond(days * 24L * 60L * 60L);
ZonedDateTime.ofInstant(instant, ZoneOffset.UTC);
}
示例7: factory_ofInstant_tooLow
@Test(expectedExceptions=DateTimeException.class)
public void factory_ofInstant_tooLow() {
long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7);
int year = Year.MIN_VALUE - 1;
long days = (year * 365L + (year / 4 - year / 100 + year / 400)) - days_0000_to_1970;
Instant instant = Instant.ofEpochSecond(days * 24L * 60L * 60L);
OffsetDateTime.ofInstant(instant, ZoneOffset.UTC);
}
示例8: factory_ofInstant_minWithMinOffset
public void factory_ofInstant_minWithMinOffset() {
long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7);
int year = Year.MIN_VALUE;
long days = (year * 365L + (year / 4 - year / 100 + year / 400)) - days_0000_to_1970;
Instant instant = Instant.ofEpochSecond(days * 24L * 60L * 60L - OFFSET_MIN.getTotalSeconds());
OffsetDateTime test = OffsetDateTime.ofInstant(instant, OFFSET_MIN);
assertEquals(test.getYear(), Year.MIN_VALUE);
assertEquals(test.getMonth().getValue(), 1);
assertEquals(test.getDayOfMonth(), 1);
assertEquals(test.getOffset(), OFFSET_MIN);
assertEquals(test.getHour(), 0);
assertEquals(test.getMinute(), 0);
assertEquals(test.getSecond(), 0);
assertEquals(test.getNano(), 0);
}
示例9: factory_ofInstant_minWithMaxOffset
public void factory_ofInstant_minWithMaxOffset() {
long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7);
int year = Year.MIN_VALUE;
long days = (year * 365L + (year / 4 - year / 100 + year / 400)) - days_0000_to_1970;
Instant instant = Instant.ofEpochSecond(days * 24L * 60L * 60L - OFFSET_MAX.getTotalSeconds());
OffsetDateTime test = OffsetDateTime.ofInstant(instant, OFFSET_MAX);
assertEquals(test.getYear(), Year.MIN_VALUE);
assertEquals(test.getMonth().getValue(), 1);
assertEquals(test.getDayOfMonth(), 1);
assertEquals(test.getOffset(), OFFSET_MAX);
assertEquals(test.getHour(), 0);
assertEquals(test.getMinute(), 0);
assertEquals(test.getSecond(), 0);
assertEquals(test.getNano(), 0);
}