Search in sources :

Example 16 with ZoneOffset

use of io.spine.time.ZoneOffset in project core-java by SpineEventEngine.

the class ChangesShould method do_not_accept_equal_OffsetDateTime_values.

@Test(expected = IllegalArgumentException.class)
public void do_not_accept_equal_OffsetDateTime_values() {
    final ZoneOffset inLuxembourg = ZoneOffsets.ofHours(1);
    final OffsetDateTime now = OffsetDateTimes.now(inLuxembourg);
    Changes.of(now, now);
}
Also used : OffsetDateTime(io.spine.time.OffsetDateTime) ZoneOffset(io.spine.time.ZoneOffset) Test(org.junit.Test)

Example 17 with ZoneOffset

use of io.spine.time.ZoneOffset in project core-java by SpineEventEngine.

the class ChangesShould method do_not_accept_null_OffsetDateTime_newValue.

@Test(expected = NullPointerException.class)
public void do_not_accept_null_OffsetDateTime_newValue() {
    final ZoneOffset inKiev = ZoneOffsets.ofHours(3);
    final OffsetDateTime now = OffsetDateTimes.now(inKiev);
    Changes.of(now, null);
}
Also used : OffsetDateTime(io.spine.time.OffsetDateTime) ZoneOffset(io.spine.time.ZoneOffset) Test(org.junit.Test)

Example 18 with ZoneOffset

use of io.spine.time.ZoneOffset in project core-java by SpineEventEngine.

the class ChangesShould method create_OffsetTimeChange_instance.

@Test
public void create_OffsetTimeChange_instance() {
    final ZoneOffset inKiev = ZoneOffsets.ofHours(3);
    final ZoneOffset inLuxembourg = ZoneOffsets.ofHours(1);
    final OffsetTime previousTime = OffsetTimes.now(inKiev);
    final OffsetTime newTime = OffsetTimes.now(inLuxembourg);
    final OffsetTimeChange result = Changes.of(previousTime, newTime);
    assertEquals(previousTime, result.getPreviousValue());
    assertEquals(newTime, result.getNewValue());
}
Also used : OffsetTime(io.spine.time.OffsetTime) ZoneOffset(io.spine.time.ZoneOffset) Test(org.junit.Test)

Example 19 with ZoneOffset

use of io.spine.time.ZoneOffset in project core-java by SpineEventEngine.

the class ZoneOffsetStringifier method fromString.

@Override
protected ZoneOffset fromString(String str) {
    checkNotNull(str);
    final ZoneOffset result;
    try {
        result = ZoneOffsets.parse(str);
    } catch (ParseException e) {
        throw illegalArgumentWithCauseOf(e);
    }
    return result;
}
Also used : ParseException(java.text.ParseException) ZoneOffset(io.spine.time.ZoneOffset)

Example 20 with ZoneOffset

use of io.spine.time.ZoneOffset in project core-java by SpineEventEngine.

the class ZoneOffsetStringifierShould method convert_negative_zone_offset.

@Test
public void convert_negative_zone_offset() {
    final Stringifier<ZoneOffset> stringifier = getStringifier();
    final ZoneOffset negative = ZoneOffsets.ofHoursMinutes(-3, -45);
    assertEquals(negative, stringifier.reverse().convert(stringifier.convert(negative)));
}
Also used : ZoneOffset(io.spine.time.ZoneOffset) Test(org.junit.Test)

Aggregations

ZoneOffset (io.spine.time.ZoneOffset)30 Test (org.junit.Test)29 OffsetDate (io.spine.time.OffsetDate)8 OffsetDateTime (io.spine.time.OffsetDateTime)8 OffsetTime (io.spine.time.OffsetTime)8 Timestamp (com.google.protobuf.Timestamp)1 ActorContext (io.spine.core.ActorContext)1 CommandContext (io.spine.core.CommandContext)1 TenantId (io.spine.core.TenantId)1 UserId (io.spine.core.UserId)1 GivenTenantId (io.spine.core.given.GivenTenantId)1 GivenUserId (io.spine.core.given.GivenUserId)1 ParseException (java.text.ParseException)1 TimeZone (java.util.TimeZone)1