当前位置: 首页>>代码示例>>Java>>正文


Java Year.MAX_VALUE属性代码示例

本文整理汇总了Java中java.time.Year.MAX_VALUE属性的典型用法代码示例。如果您正苦于以下问题:Java Year.MAX_VALUE属性的具体用法?Java Year.MAX_VALUE怎么用?Java Year.MAX_VALUE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在java.time.Year的用法示例。


在下文中一共展示了Year.MAX_VALUE属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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");
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:JapaneseChronology.java

示例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)},
    };
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:TCKYear.java

示例3: factory_ofInstant_maxWithMinOffset

@Test
public void factory_ofInstant_maxWithMinOffset() {
    long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7);
    int year = Year.MAX_VALUE;
    long days = (year * 365L + (year / 4 - year / 100 + year / 400)) + 365 - days_0000_to_1970;
    Instant instant = Instant.ofEpochSecond((days + 1) * 24L * 60L * 60L - 1 - OFFSET_MIN.getTotalSeconds());
    ZonedDateTime test = ZonedDateTime.ofInstant(instant, OFFSET_MIN);
    assertEquals(test.getYear(), Year.MAX_VALUE);
    assertEquals(test.getMonth().getValue(), 12);
    assertEquals(test.getDayOfMonth(), 31);
    assertEquals(test.getOffset(), OFFSET_MIN);
    assertEquals(test.getHour(), 23);
    assertEquals(test.getMinute(), 59);
    assertEquals(test.getSecond(), 59);
    assertEquals(test.getNano(), 0);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:TCKZonedDateTime.java

示例4: factory_ofInstant_maxWithMaxOffset

@Test
public void factory_ofInstant_maxWithMaxOffset() {
    long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7);
    int year = Year.MAX_VALUE;
    long days = (year * 365L + (year / 4 - year / 100 + year / 400)) + 365 - days_0000_to_1970;
    Instant instant = Instant.ofEpochSecond((days + 1) * 24L * 60L * 60L - 1 - OFFSET_MAX.getTotalSeconds());
    ZonedDateTime test = ZonedDateTime.ofInstant(instant, OFFSET_MAX);
    assertEquals(test.getYear(), Year.MAX_VALUE);
    assertEquals(test.getMonth().getValue(), 12);
    assertEquals(test.getDayOfMonth(), 31);
    assertEquals(test.getOffset(), OFFSET_MAX);
    assertEquals(test.getHour(), 23);
    assertEquals(test.getMinute(), 59);
    assertEquals(test.getSecond(), 59);
    assertEquals(test.getNano(), 0);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:TCKZonedDateTime.java

示例5: factory_ofInstant_maxWithMinOffset

public void factory_ofInstant_maxWithMinOffset() {
    long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7);
    int year = Year.MAX_VALUE;
    long days = (year * 365L + (year / 4 - year / 100 + year / 400)) + 365 - days_0000_to_1970;
    Instant instant = Instant.ofEpochSecond((days + 1) * 24L * 60L * 60L - 1 - OFFSET_MIN.getTotalSeconds());
    OffsetDateTime test = OffsetDateTime.ofInstant(instant, OFFSET_MIN);
    assertEquals(test.getYear(), Year.MAX_VALUE);
    assertEquals(test.getMonth().getValue(), 12);
    assertEquals(test.getDayOfMonth(), 31);
    assertEquals(test.getOffset(), OFFSET_MIN);
    assertEquals(test.getHour(), 23);
    assertEquals(test.getMinute(), 59);
    assertEquals(test.getSecond(), 59);
    assertEquals(test.getNano(), 0);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:TestOffsetDateTime_instants.java

示例6: nextTransition

/**
 * Gets the next transition after the specified instant.
 * <p>
 * This returns details of the next transition after the specified instant.
 * For example, if the instant represents a point where "Summer" daylight savings time
 * applies, then the method will return the transition to the next "Winter" time.
 *
 * @param instant  the instant to get the next transition after, not null, but null
 *  may be ignored if the rules have a single offset for all instants
 * @return the next transition after the specified instant, null if this is after the last transition
 */
public ZoneOffsetTransition nextTransition(Instant instant) {
    if (savingsInstantTransitions.length == 0) {
        return null;
    }
    long epochSec = instant.getEpochSecond();
    // check if using last rules
    if (epochSec >= savingsInstantTransitions[savingsInstantTransitions.length - 1]) {
        if (lastRules.length == 0) {
            return null;
        }
        // search year the instant is in
        int year = findYear(epochSec, wallOffsets[wallOffsets.length - 1]);
        ZoneOffsetTransition[] transArray = findTransitionArray(year);
        for (ZoneOffsetTransition trans : transArray) {
            if (epochSec < trans.toEpochSecond()) {
                return trans;
            }
        }
        // use first from following year
        if (year < Year.MAX_VALUE) {
            transArray = findTransitionArray(year + 1);
            return transArray[0];
        }
        return null;
    }

    // using historic rules
    int index  = Arrays.binarySearch(savingsInstantTransitions, epochSec);
    if (index < 0) {
        index = -index - 1;  // switched value is the next transition
    } else {
        index += 1;  // exact match, so need to add one to get the next
    }
    return new ZoneOffsetTransition(savingsInstantTransitions[index], wallOffsets[index], wallOffsets[index + 1]);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:46,代码来源:ZoneRules.java

示例7: factory_ofInstant_tooBig

@Test(expectedExceptions=DateTimeException.class)
public void factory_ofInstant_tooBig() {
    long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7);
    long year = Year.MAX_VALUE + 1L;
    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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:TestOffsetDateTime_instants.java

示例8: factory_ofInstant_tooBig

@Test(expectedExceptions=DateTimeException.class)
public void factory_ofInstant_tooBig() {
    long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7);
    long year = Year.MAX_VALUE + 1L;
    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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:TCKZonedDateTime.java

示例9: factory_ofInstant_maxWithMaxOffset

public void factory_ofInstant_maxWithMaxOffset() {
    long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7);
    int year = Year.MAX_VALUE;
    long days = (year * 365L + (year / 4 - year / 100 + year / 400)) + 365 - days_0000_to_1970;
    Instant instant = Instant.ofEpochSecond((days + 1) * 24L * 60L * 60L - 1 - OFFSET_MAX.getTotalSeconds());
    OffsetDateTime test = OffsetDateTime.ofInstant(instant, OFFSET_MAX);
    assertEquals(test.getYear(), Year.MAX_VALUE);
    assertEquals(test.getMonth().getValue(), 12);
    assertEquals(test.getDayOfMonth(), 31);
    assertEquals(test.getOffset(), OFFSET_MAX);
    assertEquals(test.getHour(), 23);
    assertEquals(test.getMinute(), 59);
    assertEquals(test.getSecond(), 59);
    assertEquals(test.getNano(), 0);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:TestOffsetDateTime_instants.java

示例10: parseYear

int parseYear(String year, int defaultYear) {
    switch (year.toLowerCase()) {
    case "min":  return 1900;
    case "max":  return Year.MAX_VALUE;
    case "only": return defaultYear;
    }
    return Integer.parseInt(year);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:TzdbZoneRulesProvider.java

示例11: 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)},
    };
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:29,代码来源:TCKYearMonth.java

示例12: test_plusYears_big

@Test
public void test_plusYears_big() {
    long years = 20L + Year.MAX_VALUE;
    assertEquals(Year.of(-40).plusYears(years), Year.of((int) (-40L + years)));
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:5,代码来源:TCKYear.java

示例13: test_plusYears_long_big

@Test
public void test_plusYears_long_big() {
    long years = 20L + Year.MAX_VALUE;
    LocalDate test = LocalDate.of(-40, 6, 1).plusYears(years);
    assertEquals(test, LocalDate.of((int) (-40L + years), 6, 1));
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:6,代码来源:TCKLocalDate.java


注:本文中的java.time.Year.MAX_VALUE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。