use of io.spine.time.ZoneOffset in project core-java by SpineEventEngine.
the class TimeChangesShould 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 = TimeChanges.of(previousTime, newTime);
assertEquals(previousTime, result.getPreviousValue());
assertEquals(newTime, result.getNewValue());
}
use of io.spine.time.ZoneOffset in project core-java by SpineEventEngine.
the class ZoneOffsetsShould method get_current_zone_offset.
@Test
public void get_current_zone_offset() {
final TimeZone timeZone = TimeZone.getDefault();
final ZoneOffset zoneOffset = ZoneOffsets.getDefault();
final Timestamp now = getCurrentTime();
final long date = Timestamps.toMillis(now);
final int offsetSeconds = timeZone.getOffset(date) / MILLIS_PER_SECOND;
final String zoneId = timeZone.getID();
assertEquals(zoneId, zoneOffset.getId());
assertEquals(offsetSeconds, zoneOffset.getAmountSeconds());
}
use of io.spine.time.ZoneOffset in project core-java by SpineEventEngine.
the class ZoneOffsetsShould method adjust_zero_offset_without_zone.
@Test
public void adjust_zero_offset_without_zone() {
Assert.assertEquals(ZoneOffsets.UTC, ZoneOffsets.adjustZero(ZoneOffsets.ofSeconds(0)));
final ZoneOffset offset = ZoneOffsets.getDefault();
Assert.assertEquals(offset, ZoneOffsets.adjustZero(offset));
final ZoneOffset gmtOffset = ZoneConverter.getInstance().convert(TimeZone.getTimeZone("GMT"));
checkNotNull(gmtOffset);
Assert.assertEquals(gmtOffset, ZoneOffsets.adjustZero(gmtOffset));
}
use of io.spine.time.ZoneOffset in project core-java by SpineEventEngine.
the class TimeChangesShould method do_not_accept_equal_OffsetDate_values.
@Test(expected = IllegalArgumentException.class)
public void do_not_accept_equal_OffsetDate_values() {
final ZoneOffset inLuxembourg = ZoneOffsets.ofHours(1);
final OffsetDate date = OffsetDates.now(inLuxembourg);
TimeChanges.of(date, date);
}
use of io.spine.time.ZoneOffset in project core-java by SpineEventEngine.
the class TimeChangesShould method do_not_accept_null_OffsetTime_newValue.
@Test(expected = NullPointerException.class)
public void do_not_accept_null_OffsetTime_newValue() {
final ZoneOffset inKiev = ZoneOffsets.ofHours(3);
final OffsetTime now = OffsetTimes.now(inKiev);
TimeChanges.of(now, null);
}
Aggregations