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


Java OffsetTime.of方法代碼示例

本文整理匯總了Java中java.time.OffsetTime.of方法的典型用法代碼示例。如果您正苦於以下問題:Java OffsetTime.of方法的具體用法?Java OffsetTime.of怎麽用?Java OffsetTime.of使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.time.OffsetTime的用法示例。


在下文中一共展示了OffsetTime.of方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: test_isBeforeIsAfterIsEqual2nanos

import java.time.OffsetTime; //導入方法依賴的package包/類
@Test
public void test_isBeforeIsAfterIsEqual2nanos() {
    OffsetTime a = OffsetTime.of(11, 30, 59, 4, ZoneOffset.ofTotalSeconds(OFFSET_PONE.getTotalSeconds() + 1));
    OffsetTime b = OffsetTime.of(11, 30, 59, 3, OFFSET_PONE);  // a is before b due to offset
    assertEquals(a.isBefore(b), true);
    assertEquals(a.isEqual(b), false);
    assertEquals(a.isAfter(b), false);

    assertEquals(b.isBefore(a), false);
    assertEquals(b.isEqual(a), false);
    assertEquals(b.isAfter(a), true);

    assertEquals(a.isBefore(a), false);
    assertEquals(b.isBefore(b), false);

    assertEquals(a.isEqual(a), true);
    assertEquals(b.isEqual(b), true);

    assertEquals(a.isAfter(a), false);
    assertEquals(b.isAfter(b), false);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:22,代碼來源:TCKOffsetTime.java

示例2: data_adjustInto

import java.time.OffsetTime; //導入方法依賴的package包/類
@DataProvider(name="adjustInto")
Object[][] data_adjustInto() {
    return new Object[][]{
            {LocalDateTime.of(2012, 3, 4, 23, 5), LocalDateTime.of(2012, 3, 4, 1, 1, 1, 100), LocalDateTime.of(2012, 3, 4, 23, 5, 0, 0), null},
            {LocalDateTime.of(2012, Month.MARCH, 4, 0, 0), LocalDateTime.of(2012, 3, 4, 1, 1, 1, 100), LocalDateTime.of(2012, 3, 4, 0, 0), null},
            {LocalDateTime.of(2012, 3, 4, 23, 5), LocalDateTime.MAX, LocalDateTime.of(2012, 3, 4, 23, 5), null},
            {LocalDateTime.of(2012, 3, 4, 23, 5), LocalDateTime.MIN, LocalDateTime.of(2012, 3, 4, 23, 5), null},
            {LocalDateTime.MAX, LocalDateTime.of(2012, 3, 4, 23, 5), LocalDateTime.MAX, null},
            {LocalDateTime.MIN, LocalDateTime.of(2012, 3, 4, 23, 5), LocalDateTime.MIN, null},

            {LocalDateTime.of(2012, 3, 4, 23, 5), OffsetDateTime.of(2210, 2, 2, 0, 0, 0, 0, ZoneOffset.UTC), OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, ZoneOffset.UTC), null},
            {LocalDateTime.of(2012, 3, 4, 23, 5), OffsetDateTime.of(2210, 2, 2, 0, 0, 0, 0, OFFSET_PONE), OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, OFFSET_PONE), null},
            {LocalDateTime.of(2012, 3, 4, 23, 5), ZonedDateTime.of(2210, 2, 2, 0, 0, 0, 0, ZONE_PARIS), ZonedDateTime.of(2012, 3, 4, 23, 5, 0, 0, ZONE_PARIS), null},

            {LocalDateTime.of(2012, 3, 4, 23, 5), LocalDate.of(2210, 2, 2), null, DateTimeException.class},
            {LocalDateTime.of(2012, 3, 4, 23, 5), LocalTime.of(22, 3, 0), null, DateTimeException.class},
            {LocalDateTime.of(2012, 3, 4, 23, 5), OffsetTime.of(22, 3, 0, 0, ZoneOffset.UTC), null, DateTimeException.class},
            {LocalDateTime.of(2012, 3, 4, 23, 5), null, null, NullPointerException.class},

    };
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:22,代碼來源:TCKLocalDateTime.java

示例3: test_isBeforeIsAfterIsEqual1nanos

import java.time.OffsetTime; //導入方法依賴的package包/類
@Test
public void test_isBeforeIsAfterIsEqual1nanos() {
    OffsetTime a = OffsetTime.of(11, 30, 59, 3, OFFSET_PONE);
    OffsetTime b = OffsetTime.of(11, 30, 59, 4, OFFSET_PONE);  // a is before b due to time
    assertEquals(a.isBefore(b), true);
    assertEquals(a.isEqual(b), false);
    assertEquals(a.isAfter(b), false);

    assertEquals(b.isBefore(a), false);
    assertEquals(b.isEqual(a), false);
    assertEquals(b.isAfter(a), true);

    assertEquals(a.isBefore(a), false);
    assertEquals(b.isBefore(b), false);

    assertEquals(a.isEqual(a), true);
    assertEquals(b.isEqual(b), true);

    assertEquals(a.isAfter(a), false);
    assertEquals(b.isAfter(b), false);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:22,代碼來源:TCKOffsetTime.java

示例4: test_with_adjuster_OffsetTime_validOffsetIntoOverlap1

import java.time.OffsetTime; //導入方法依賴的package包/類
@Test
public void test_with_adjuster_OffsetTime_validOffsetIntoOverlap1() {
    // OT has valid offset for resulting time
    OffsetTime ot = OffsetTime.of(2, 30, 30, 40, OFFSET_0100);  // valid offset in overlap
    ZonedDateTime zdt = dateTime(2008, 10, 26, 0, 0, 0, 0, OFFSET_0200, ZONE_PARIS);  // just before overlap
    ZonedDateTime test = zdt.with(ot);
    assertEquals(test.toLocalDateTime(), dateTime(2008, 10, 26, 2, 30, 30, 40));
    assertEquals(test.getOffset(), OFFSET_0100);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:10,代碼來源:TCKZonedDateTime.java

示例5: test_equals_false_minute_differs

import java.time.OffsetTime; //導入方法依賴的package包/類
@Test(dataProvider="sampleTimes")
public void test_equals_false_minute_differs(int h, int m, int s, int n, ZoneOffset ignored) {
    m = (m == 59 ? 58 : m);
    OffsetTime a = OffsetTime.of(h, m, s, n, OFFSET_PONE);
    OffsetTime b = OffsetTime.of(h, m + 1, s, n, OFFSET_PONE);
    assertEquals(a.equals(b), false);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:8,代碼來源:TCKOffsetTime.java

示例6: test_equals_false_second_differs

import java.time.OffsetTime; //導入方法依賴的package包/類
@Test(dataProvider="sampleTimes")
public void test_equals_false_second_differs(int h, int m, int s, int n, ZoneOffset ignored) {
    s = (s == 59 ? 58 : s);
    OffsetTime a = OffsetTime.of(h, m, s, n, OFFSET_PONE);
    OffsetTime b = OffsetTime.of(h, m, s + 1, n, OFFSET_PONE);
    assertEquals(a.equals(b), false);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:8,代碼來源:TCKOffsetTime.java

示例7: test_with_TemporalField

import java.time.OffsetTime; //導入方法依賴的package包/類
@Test
public void test_with_TemporalField() {
    OffsetTime test = OffsetTime.of(12, 30, 40, 987654321, OFFSET_PONE);
    assertEquals(test.with(ChronoField.HOUR_OF_DAY, 15), OffsetTime.of(15, 30, 40, 987654321, OFFSET_PONE));
    assertEquals(test.with(ChronoField.MINUTE_OF_HOUR, 50), OffsetTime.of(12, 50, 40, 987654321, OFFSET_PONE));
    assertEquals(test.with(ChronoField.SECOND_OF_MINUTE, 50), OffsetTime.of(12, 30, 50, 987654321, OFFSET_PONE));
    assertEquals(test.with(ChronoField.NANO_OF_SECOND, 12345), OffsetTime.of(12, 30, 40, 12345, OFFSET_PONE));
    assertEquals(test.with(ChronoField.HOUR_OF_AMPM, 6), OffsetTime.of(18, 30, 40, 987654321, OFFSET_PONE));
    assertEquals(test.with(ChronoField.AMPM_OF_DAY, 0), OffsetTime.of(0, 30, 40, 987654321, OFFSET_PONE));

    assertEquals(test.with(ChronoField.OFFSET_SECONDS, 7205), OffsetTime.of(12, 30, 40, 987654321, ZoneOffset.ofHoursMinutesSeconds(2, 0, 5)));
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:13,代碼來源:TCKOffsetTime.java

示例8: test_compareTo_offset

import java.time.OffsetTime; //導入方法依賴的package包/類
@Test
public void test_compareTo_offset() {
    OffsetTime a = OffsetTime.of(11, 30, 0, 0, OFFSET_PTWO);
    OffsetTime b = OffsetTime.of(11, 30, 0, 0, OFFSET_PONE);  // a is before b due to offset
    assertEquals(a.compareTo(b) < 0, true);
    assertEquals(b.compareTo(a) > 0, true);
    assertEquals(a.compareTo(a) == 0, true);
    assertEquals(b.compareTo(b) == 0, true);
    assertEquals(convertInstant(a).compareTo(convertInstant(b)) < 0, true);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:11,代碼來源:TCKOffsetTime.java

示例9: test_compareTo_time

import java.time.OffsetTime; //導入方法依賴的package包/類
@Test
public void test_compareTo_time() {
    OffsetTime a = OffsetTime.of(11, 29, 0, 0, OFFSET_PONE);
    OffsetTime b = OffsetTime.of(11, 30, 0, 0, OFFSET_PONE);  // a is before b due to time
    assertEquals(a.compareTo(b) < 0, true);
    assertEquals(b.compareTo(a) > 0, true);
    assertEquals(a.compareTo(a) == 0, true);
    assertEquals(b.compareTo(b) == 0, true);
    assertEquals(convertInstant(a).compareTo(convertInstant(b)) < 0, true);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:11,代碼來源:TCKOffsetTime.java

示例10: test_plusNanos

import java.time.OffsetTime; //導入方法依賴的package包/類
@Test
public void test_plusNanos() {
    OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
    OffsetTime test = base.plusNanos(1);
    assertEquals(test, OffsetTime.of(11, 30, 59, 1, OFFSET_PONE));
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:7,代碼來源:TCKOffsetTime.java

示例11: test_withMinute_normal

import java.time.OffsetTime; //導入方法依賴的package包/類
@Test
public void test_withMinute_normal() {
    OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
    OffsetTime test = base.withMinute(15);
    assertEquals(test, OffsetTime.of(11, 15, 59, 0, OFFSET_PONE));
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:7,代碼來源:TCKOffsetTime.java

示例12: setUp

import java.time.OffsetTime; //導入方法依賴的package包/類
@BeforeMethod
public void setUp() {
    TEST_11_30_59_500_PONE = OffsetTime.of(11, 30, 59, 500, OFFSET_PONE);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:5,代碼來源:TCKOffsetTimeSerialization.java

示例13: test_withMinute_noChange

import java.time.OffsetTime; //導入方法依賴的package包/類
@Test
public void test_withMinute_noChange() {
    OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
    OffsetTime test = base.withMinute(30);
    assertEquals(test, base);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:7,代碼來源:TCKOffsetTime.java

示例14: test_withSecond_noChange

import java.time.OffsetTime; //導入方法依賴的package包/類
@Test
public void test_withSecond_noChange() {
    OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
    OffsetTime test = base.withSecond(59);
    assertEquals(test, base);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:7,代碼來源:TCKOffsetTime.java

示例15: test_minusNanos_zero

import java.time.OffsetTime; //導入方法依賴的package包/類
@Test
public void test_minusNanos_zero() {
    OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
    OffsetTime test = base.minusNanos(0);
    assertEquals(test, base);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:7,代碼來源:TCKOffsetTime.java


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