本文整理匯總了Java中java.time.OffsetTime.now方法的典型用法代碼示例。如果您正苦於以下問題:Java OffsetTime.now方法的具體用法?Java OffsetTime.now怎麽用?Java OffsetTime.now使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.time.OffsetTime
的用法示例。
在下文中一共展示了OffsetTime.now方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setOffsetTime
import java.time.OffsetTime; //導入方法依賴的package包/類
@Test
public void setOffsetTime() {
final OffsetTime value = OffsetTime.now();
final Iterator<Value<?>> it = ps.setOffsetTime(value).params().iterator();
assertEquals(new OffsetTimeValue(value), it.next());
assertFalse(it.hasNext());
}
示例2: setOffsetTimePositional
import java.time.OffsetTime; //導入方法依賴的package包/類
@Test
public void setOffsetTimePositional() {
final OffsetTime value = OffsetTime.now();
final Iterator<Value<?>> it = ps.setOffsetTime(0, value).params().iterator();
assertEquals(new OffsetTimeValue(value), it.next());
assertFalse(it.hasNext());
}
示例3: now
import java.time.OffsetTime; //導入方法依賴的package包/類
@Test
public void now() {
ZonedDateTime nowDT = ZonedDateTime.now();
OffsetTime expected = OffsetTime.now(Clock.systemDefaultZone());
OffsetTime test = OffsetTime.now();
long diff = Math.abs(test.toLocalTime().toNanoOfDay() - expected.toLocalTime().toNanoOfDay());
assertTrue(diff < 100000000); // less than 0.1 secs
assertEquals(test.getOffset(), nowDT.getOffset());
}
示例4: now_Clock_allSecsInDay
import java.time.OffsetTime; //導入方法依賴的package包/類
@Test
public void now_Clock_allSecsInDay() {
for (int i = 0; i < (2 * 24 * 60 * 60); i++) {
Instant instant = Instant.ofEpochSecond(i, 8);
Clock clock = Clock.fixed(instant, ZoneOffset.UTC);
OffsetTime test = OffsetTime.now(clock);
assertEquals(test.getHour(), (i / (60 * 60)) % 24);
assertEquals(test.getMinute(), (i / 60) % 60);
assertEquals(test.getSecond(), i % 60);
assertEquals(test.getNano(), 8);
assertEquals(test.getOffset(), ZoneOffset.UTC);
}
}
示例5: now_Clock_beforeEpoch
import java.time.OffsetTime; //導入方法依賴的package包/類
@Test
public void now_Clock_beforeEpoch() {
for (int i =-1; i >= -(24 * 60 * 60); i--) {
Instant instant = Instant.ofEpochSecond(i, 8);
Clock clock = Clock.fixed(instant, ZoneOffset.UTC);
OffsetTime test = OffsetTime.now(clock);
assertEquals(test.getHour(), ((i + 24 * 60 * 60) / (60 * 60)) % 24);
assertEquals(test.getMinute(), ((i + 24 * 60 * 60) / 60) % 60);
assertEquals(test.getSecond(), (i + 24 * 60 * 60) % 60);
assertEquals(test.getNano(), 8);
assertEquals(test.getOffset(), ZoneOffset.UTC);
}
}
示例6: now_Clock_offsets
import java.time.OffsetTime; //導入方法依賴的package包/類
@Test
public void now_Clock_offsets() {
Instant base = LocalDateTime.of(1970, 1, 1, 12, 0).toInstant(ZoneOffset.UTC);
for (int i = -9; i < 15; i++) {
ZoneOffset offset = ZoneOffset.ofHours(i);
Clock clock = Clock.fixed(base, offset);
OffsetTime test = OffsetTime.now(clock);
assertEquals(test.getHour(), (12 + i) % 24);
assertEquals(test.getMinute(), 0);
assertEquals(test.getSecond(), 0);
assertEquals(test.getNano(), 0);
assertEquals(test.getOffset(), offset);
}
}
示例7: getOffsetTime
import java.time.OffsetTime; //導入方法依賴的package包/類
@Test
public void getOffsetTime() {
final OffsetTime value = OffsetTime.now();
final OffsetTimeValue wrapper = new OffsetTimeValue(value);
assertEquals(value, wrapper.getOffsetTime());
}
示例8: getLocalTime
import java.time.OffsetTime; //導入方法依賴的package包/類
@Test
public void getLocalTime() {
final OffsetTime value = OffsetTime.now();
final OffsetTimeValue wrapper = new OffsetTimeValue(value);
assertEquals(value.toLocalTime(), wrapper.getLocalTime());
}
示例9: OffsetTestEntity
import java.time.OffsetTime; //導入方法依賴的package包/類
public OffsetTestEntity(final long id) {
this.id = id;
this.datetimeValue = OffsetDateTime.now();
this.timeValue = OffsetTime.now();
}
示例10: now_Clock_nullZoneId
import java.time.OffsetTime; //導入方法依賴的package包/類
@Test(expectedExceptions=NullPointerException.class)
public void now_Clock_nullZoneId() {
OffsetTime.now((ZoneId) null);
}
示例11: now_Clock_nullClock
import java.time.OffsetTime; //導入方法依賴的package包/類
@Test(expectedExceptions=NullPointerException.class)
public void now_Clock_nullClock() {
OffsetTime.now((Clock) null);
}