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


Java Year.of方法代码示例

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


在下文中一共展示了Year.of方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: data_plus_long_TemporalUnit

import java.time.Year; //导入方法依赖的package包/类
@DataProvider(name="plus_long_TemporalUnit")
Object[][] data_plus_long_TemporalUnit() {
    return new Object[][] {
        {Year.of(1), 1, ChronoUnit.YEARS, Year.of(2), null},
        {Year.of(1), -12, ChronoUnit.YEARS, Year.of(-11), null},
        {Year.of(1), 0, ChronoUnit.YEARS, Year.of(1), null},
        {Year.of(999999999), 0, ChronoUnit.YEARS, Year.of(999999999), null},
        {Year.of(-999999999), 0, ChronoUnit.YEARS, Year.of(-999999999), null},
        {Year.of(0), -999999999, ChronoUnit.YEARS, Year.of(-999999999), null},
        {Year.of(0), 999999999, ChronoUnit.YEARS, Year.of(999999999), null},

        {Year.of(-1), 1, ChronoUnit.ERAS, Year.of(2), null},
        {Year.of(5), 1, ChronoUnit.CENTURIES, Year.of(105), null},
        {Year.of(5), 1, ChronoUnit.DECADES, Year.of(15), null},

        {Year.of(999999999), 1, ChronoUnit.YEARS, null, DateTimeException.class},
        {Year.of(-999999999), -1, ChronoUnit.YEARS, null, DateTimeException.class},

        {Year.of(1), 0, ChronoUnit.DAYS, null, DateTimeException.class},
        {Year.of(1), 0, ChronoUnit.WEEKS, null, DateTimeException.class},
        {Year.of(1), 0, ChronoUnit.MONTHS, null, DateTimeException.class},
    };
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:TCKYear.java

示例2: provider_goodParseData

import java.time.Year; //导入方法依赖的package包/类
@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:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:TCKYear.java

示例3: data_minus_long_TemporalUnit

import java.time.Year; //导入方法依赖的package包/类
@DataProvider(name="minus_long_TemporalUnit")
Object[][] data_minus_long_TemporalUnit() {
    return new Object[][] {
        {Year.of(1), 1, ChronoUnit.YEARS, Year.of(0), null},
        {Year.of(1), -12, ChronoUnit.YEARS, Year.of(13), null},
        {Year.of(1), 0, ChronoUnit.YEARS, Year.of(1), null},
        {Year.of(999999999), 0, ChronoUnit.YEARS, Year.of(999999999), null},
        {Year.of(-999999999), 0, ChronoUnit.YEARS, Year.of(-999999999), null},
        {Year.of(0), -999999999, ChronoUnit.YEARS, Year.of(999999999), null},
        {Year.of(0), 999999999, ChronoUnit.YEARS, Year.of(-999999999), null},

        {Year.of(999999999), 1, ChronoUnit.ERAS, Year.of(-999999999 + 1), null},
        {Year.of(105), 1, ChronoUnit.CENTURIES, Year.of(5), null},
        {Year.of(15), 1, ChronoUnit.DECADES, Year.of(5), null},

        {Year.of(-999999999), 1, ChronoUnit.YEARS, null, DateTimeException.class},
        {Year.of(1), -999999999, ChronoUnit.YEARS, null, DateTimeException.class},

        {Year.of(1), 0, ChronoUnit.DAYS, null, DateTimeException.class},
        {Year.of(1), 0, ChronoUnit.WEEKS, null, DateTimeException.class},
        {Year.of(1), 0, ChronoUnit.MONTHS, null, DateTimeException.class},
    };
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:TCKYear.java

示例4: test_factory_int_singleton

import java.time.Year; //导入方法依赖的package包/类
@Test
public void test_factory_int_singleton() {
    for (int i = -4; i <= 2104; i++) {
        Year test = Year.of(i);
        assertEquals(test.getValue(), i);
        assertEquals(Year.of(i), test);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:TCKYear.java

示例5: shouldUseFirstVersionOfYearWhenVersionNotInYearlyFormat

import java.time.Year; //导入方法依赖的package包/类
@Test
public void shouldUseFirstVersionOfYearWhenVersionNotInYearlyFormat() throws Exception {
    testee = new YearlyVersionPolicy(Year.of(2017));

    result = testee.getDevelopmentVersion(version("1.2.3"));

    assertThat(result.getVersion(), is("2017.1-SNAPSHOT"));
}
 
开发者ID:ncredinburgh,项目名称:maven-release-yearly-policy,代码行数:9,代码来源:YearlyVersionPolicyTest.java

示例6: shouldIgnoreSnapshotVersionIfNotInYearForm

import java.time.Year; //导入方法依赖的package包/类
@Test
public void shouldIgnoreSnapshotVersionIfNotInYearForm() throws Exception {
    testee = new YearlyVersionPolicy(Year.of(2017));

    result = testee.getReleaseVersion(version("1.2.3-SNAPSHOT"));

    assertThat(result.getVersion(), is("2017.1"));
}
 
开发者ID:ncredinburgh,项目名称:maven-release-yearly-policy,代码行数:9,代码来源:YearlyVersionPolicyTest.java

示例7: testRangeWithMapping

import java.time.Year; //导入方法依赖的package包/类
@Test()
 public void testRangeWithMapping() {
     final Range<Year> range = Range.of(1990, 2014).map(Year::of);
     final Array<Year> array = range.toArray();
     Assert.assertEquals(array.typeCode(), ArrayType.YEAR);
     Assert.assertTrue(!array.style().isSparse());
     Assert.assertEquals(array.length(), 2014-1990);
     Assert.assertEquals(range.start(), Year.of(1990), "The range start");
     Assert.assertEquals(range.end(), Year.of(2014), "The range end");
     for (int i=1990; i<2014; ++i) {
         final Year expected = Year.of(i);
         Assert.assertEquals(array.getValue(i-1990), expected, "Value matches at " + i);
     }
}
 
开发者ID:zavtech,项目名称:morpheus-core,代码行数:15,代码来源:RangeBasicTests.java

示例8: shouldPreserveExtraSubVersion

import java.time.Year; //导入方法依赖的package包/类
@Test
public void shouldPreserveExtraSubVersion() throws Exception {
    testee = new YearlyVersionPolicy(Year.of(2017));

    result = testee.getReleaseVersion(version("2017.3.2.1-SNAPSHOT"));

    assertThat(result.getVersion(), is("2017.3.2.1"));
}
 
开发者ID:ncredinburgh,项目名称:maven-release-yearly-policy,代码行数:9,代码来源:YearlyVersionPolicyTest.java

示例9: test_toString

import java.time.Year; //导入方法依赖的package包/类
@Test
public void test_toString() {
    for (int i = -4; i <= 2104; i++) {
        Year a = Year.of(i);
        assertEquals(a.toString(), "" + i);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:TCKYear.java

示例10: test_compareTo

import java.time.Year; //导入方法依赖的package包/类
@Test
public void test_compareTo() {
    for (int i = -4; i <= 2104; i++) {
        Year a = Year.of(i);
        for (int j = -4; j <= 2104; j++) {
            Year b = Year.of(j);
            if (i < j) {
                assertEquals(a.compareTo(b) < 0, true);
                assertEquals(b.compareTo(a) > 0, true);
                assertEquals(a.isAfter(b), false);
                assertEquals(a.isBefore(b), true);
                assertEquals(b.isAfter(a), true);
                assertEquals(b.isBefore(a), false);
            } else if (i > j) {
                assertEquals(a.compareTo(b) > 0, true);
                assertEquals(b.compareTo(a) < 0, true);
                assertEquals(a.isAfter(b), true);
                assertEquals(a.isBefore(b), false);
                assertEquals(b.isAfter(a), false);
                assertEquals(b.isBefore(a), true);
            } else {
                assertEquals(a.compareTo(b), 0);
                assertEquals(b.compareTo(a), 0);
                assertEquals(a.isAfter(b), false);
                assertEquals(a.isBefore(b), false);
                assertEquals(b.isAfter(a), false);
                assertEquals(b.isBefore(a), false);
            }
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:32,代码来源:TCKYear.java

示例11: test_with_BadTemporalAdjuster

import java.time.Year; //导入方法依赖的package包/类
@Test(expectedExceptions=DateTimeException.class)
public void test_with_BadTemporalAdjuster() {
    Year test = Year.of(1);
    test.with(LocalTime.of(18, 1, 2));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:TCKYear.java

示例12: test_factory_int_tooHigh

import java.time.Year; //导入方法依赖的package包/类
@Test(expectedExceptions=DateTimeException.class)
public void test_factory_int_tooHigh() {
    Year.of(Year.MAX_VALUE + 1);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:5,代码来源:TCKYear.java

示例13: test_minusYear_zero_equals

import java.time.Year; //导入方法依赖的package包/类
@Test
public void test_minusYear_zero_equals() {
    Year base = Year.of(2007);
    assertEquals(base.minusYears(0), base);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:TCKYear.java

示例14: test_atDay_day0

import java.time.Year; //导入方法依赖的package包/类
@Test(expectedExceptions=DateTimeException.class)
public void test_atDay_day0() {
    Year test = Year.of(2007);
    test.atDay(0);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:6,代码来源:TCKYear.java

示例15: test_atMonth_int_invalidMonth

import java.time.Year; //导入方法依赖的package包/类
@Test(expectedExceptions=DateTimeException.class)
public void test_atMonth_int_invalidMonth() {
    Year test = Year.of(2008);
    test.atMonth(13);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:TCKYear.java


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