當前位置: 首頁>>代碼示例>>Java>>正文


Java OffsetTime.now方法代碼示例

本文整理匯總了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());
}
 
開發者ID:traneio,項目名稱:ndbc,代碼行數:8,代碼來源:PreparedStatementTest.java

示例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());
}
 
開發者ID:traneio,項目名稱:ndbc,代碼行數:8,代碼來源:PreparedStatementTest.java

示例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());
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:11,代碼來源:TCKOffsetTime.java

示例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);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:14,代碼來源:TCKOffsetTime.java

示例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);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:14,代碼來源:TCKOffsetTime.java

示例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);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:15,代碼來源:TCKOffsetTime.java

示例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());
}
 
開發者ID:traneio,項目名稱:ndbc,代碼行數:7,代碼來源:OffsetTimeValueTest.java

示例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());
}
 
開發者ID:traneio,項目名稱:ndbc,代碼行數:7,代碼來源:OffsetTimeValueTest.java

示例9: OffsetTestEntity

import java.time.OffsetTime; //導入方法依賴的package包/類
public OffsetTestEntity(final long id) {
	this.id = id;
	this.datetimeValue = OffsetDateTime.now();
	this.timeValue = OffsetTime.now();
}
 
開發者ID:future-architect,項目名稱:uroborosql,代碼行數:6,代碼來源:DateTimeTest.java

示例10: now_Clock_nullZoneId

import java.time.OffsetTime; //導入方法依賴的package包/類
@Test(expectedExceptions=NullPointerException.class)
public void now_Clock_nullZoneId() {
    OffsetTime.now((ZoneId) null);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:5,代碼來源:TCKOffsetTime.java

示例11: now_Clock_nullClock

import java.time.OffsetTime; //導入方法依賴的package包/類
@Test(expectedExceptions=NullPointerException.class)
public void now_Clock_nullClock() {
    OffsetTime.now((Clock) null);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:5,代碼來源:TCKOffsetTime.java


注:本文中的java.time.OffsetTime.now方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。