本文整理汇总了Java中java.time.Year.now方法的典型用法代码示例。如果您正苦于以下问题:Java Year.now方法的具体用法?Java Year.now怎么用?Java Year.now使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.Year
的用法示例。
在下文中一共展示了Year.now方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: now
import java.time.Year; //导入方法依赖的package包/类
@Test
public void now() {
Year expected = Year.now(Clock.systemDefaultZone());
Year test = Year.now();
for (int i = 0; i < 100; i++) {
if (expected.equals(test)) {
return;
}
expected = Year.now(Clock.systemDefaultZone());
test = Year.now();
}
assertEquals(test, expected);
}
示例2: now_ZoneId
import java.time.Year; //导入方法依赖的package包/类
@Test
public void now_ZoneId() {
ZoneId zone = ZoneId.of("UTC+01:02:03");
Year expected = Year.now(Clock.system(zone));
Year test = Year.now(zone);
for (int i = 0; i < 100; i++) {
if (expected.equals(test)) {
return;
}
expected = Year.now(Clock.system(zone));
test = Year.now(zone);
}
assertEquals(test, expected);
}
示例3: now_Clock
import java.time.Year; //导入方法依赖的package包/类
@Test
public void now_Clock() {
Instant instant = OffsetDateTime.of(LocalDate.of(2010, 12, 31), LocalTime.of(0, 0), ZoneOffset.UTC).toInstant();
Clock clock = Clock.fixed(instant, ZoneOffset.UTC);
Year test = Year.now(clock);
assertEquals(test.getValue(), 2010);
}
示例4: now_ZoneId_nullZoneId
import java.time.Year; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void now_ZoneId_nullZoneId() {
Year.now((ZoneId) null);
}
示例5: now_Clock_nullClock
import java.time.Year; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void now_Clock_nullClock() {
Year.now((Clock) null);
}
示例6: YearlyVersionPolicy
import java.time.Year; //导入方法依赖的package包/类
public YearlyVersionPolicy() {
this(Year.now());
}