Search in sources :

Example 86 with ZoneOffset

use of java.time.ZoneOffset in project j2objc by google.

the class TCKZoneOffset method test_compareTo.

// -----------------------------------------------------------------------
// compareTo()
// -----------------------------------------------------------------------
@Test
public void test_compareTo() {
    ZoneOffset offset1 = ZoneOffset.ofHoursMinutesSeconds(1, 2, 3);
    ZoneOffset offset2 = ZoneOffset.ofHoursMinutesSeconds(2, 3, 4);
    assertTrue(offset1.compareTo(offset2) > 0);
    assertTrue(offset2.compareTo(offset1) < 0);
    assertTrue(offset1.compareTo(offset1) == 0);
    assertTrue(offset2.compareTo(offset2) == 0);
}
Also used : ZoneOffset(java.time.ZoneOffset) Test(org.junit.Test)

Example 87 with ZoneOffset

use of java.time.ZoneOffset in project j2objc by google.

the class TCKZoneOffset method test_equals.

// -----------------------------------------------------------------------
// equals() / hashCode()
// -----------------------------------------------------------------------
@Test
public void test_equals() {
    ZoneOffset offset1 = ZoneOffset.ofHoursMinutesSeconds(1, 2, 3);
    ZoneOffset offset2 = ZoneOffset.ofHoursMinutesSeconds(2, 3, 4);
    ZoneOffset offset2b = ZoneOffset.ofHoursMinutesSeconds(2, 3, 4);
    assertEquals(offset1.equals(offset2), false);
    assertEquals(offset2.equals(offset1), false);
    assertEquals(offset1.equals(offset1), true);
    assertEquals(offset2.equals(offset2), true);
    assertEquals(offset2.equals(offset2b), true);
    assertEquals(offset1.hashCode() == offset1.hashCode(), true);
    assertEquals(offset2.hashCode() == offset2.hashCode(), true);
    assertEquals(offset2.hashCode() == offset2b.hashCode(), true);
}
Also used : ZoneOffset(java.time.ZoneOffset) Test(org.junit.Test)

Example 88 with ZoneOffset

use of java.time.ZoneOffset in project j2objc by google.

the class TCKZoneOffset method test_constant_UTC.

// -----------------------------------------------------------------------
// constants
// -----------------------------------------------------------------------
@Test
public void test_constant_UTC() {
    ZoneOffset test = ZoneOffset.UTC;
    doTestOffset(test, 0, 0, 0);
}
Also used : ZoneOffset(java.time.ZoneOffset) Test(org.junit.Test)

Example 89 with ZoneOffset

use of java.time.ZoneOffset in project j2objc by google.

the class TCKOffsetDateTime method now_Clock_offsets.

@Test
public void now_Clock_offsets() {
    OffsetDateTime base = OffsetDateTime.of(1970, 1, 1, 12, 0, 0, 0, ZoneOffset.UTC);
    for (int i = -9; i < 15; i++) {
        ZoneOffset offset = ZoneOffset.ofHours(i);
        Clock clock = Clock.fixed(base.toInstant(), offset);
        OffsetDateTime test = OffsetDateTime.now(clock);
        assertEquals(test.getHour(), (12 + i) % 24);
        assertEquals(test.getMinute(), 0);
        assertEquals(test.getSecond(), 0);
        assertEquals(test.getNano(), 0);
        assertEquals(test.getOffset(), offset);
    }
}
Also used : OffsetDateTime(java.time.OffsetDateTime) Clock(java.time.Clock) ZoneOffset(java.time.ZoneOffset) Test(org.junit.Test)

Example 90 with ZoneOffset

use of java.time.ZoneOffset in project j2objc by google.

the class TCKZoneId method test_invalidPrefixOfOffset.

@Test(expected = java.lang.IllegalArgumentException.class)
@UseDataProvider("data_prefixInvalid")
public void test_invalidPrefixOfOffset(String prefix, String offset) {
    ZoneOffset zoff = ZoneOffset.of(offset);
    ZoneId zoneId = ZoneId.ofOffset(prefix, zoff);
    fail("should have thrown an exception for prefix: " + prefix);
}
Also used : ZoneId(java.time.ZoneId) ZoneOffset(java.time.ZoneOffset) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Aggregations

ZoneOffset (java.time.ZoneOffset)201 Test (org.junit.Test)51 LocalDateTime (java.time.LocalDateTime)36 ZoneId (java.time.ZoneId)36 Test (org.testng.annotations.Test)35 ZonedDateTime (java.time.ZonedDateTime)27 LocalTime (java.time.LocalTime)25 ZoneRules (java.time.zone.ZoneRules)23 OffsetDateTime (java.time.OffsetDateTime)20 Instant (java.time.Instant)17 LocalDate (java.time.LocalDate)16 TemporalAccessor (java.time.temporal.TemporalAccessor)11 ZoneOffsetTransition (java.time.zone.ZoneOffsetTransition)11 OffsetTime (java.time.OffsetTime)10 DateTimeFormatter (java.time.format.DateTimeFormatter)10 ArrayList (java.util.ArrayList)8 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)7 List (java.util.List)6 BigDecimal (java.math.BigDecimal)5 Clock (java.time.Clock)5