本文整理匯總了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());
}