本文整理汇总了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},
};
}
示例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)},
};
}
示例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},
};
}
示例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);
}
}
示例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"));
}
示例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"));
}
示例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);
}
}
示例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"));
}
示例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);
}
}
示例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);
}
}
}
}
示例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));
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}