Search in sources :

Example 6 with LocalTime

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

the class TimeChangesShould method create_LocalTimeChange_instance.

@Test
public void create_LocalTimeChange_instance() {
    final LocalTime now = LocalTimes.now();
    final LocalTime inFiveHours = LocalTimes.addHours(now, 5);
    final LocalTimeChange result = TimeChanges.of(now, inFiveHours);
    assertEquals(now, result.getPreviousValue());
    assertEquals(inFiveHours, result.getNewValue());
}
Also used : LocalTime(io.spine.time.LocalTime) LocalTimeChange(io.spine.time.change.LocalTimeChange) Test(org.junit.Test)

Example 7 with LocalTime

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

the class ChangesShould method do_not_accept_null_LocalTime_newValue.

@Test(expected = NullPointerException.class)
public void do_not_accept_null_LocalTime_newValue() {
    final LocalTime now = LocalTimes.now();
    Changes.of(now, null);
}
Also used : LocalTime(io.spine.time.LocalTime) Test(org.junit.Test)

Example 8 with LocalTime

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

the class ChangesShould method create_LocalTimeChange_instance.

@Test
public void create_LocalTimeChange_instance() {
    final LocalTime now = LocalTimes.now();
    final LocalTime inFiveHours = LocalTimes.addHours(now, 5);
    final LocalTimeChange result = Changes.of(now, inFiveHours);
    assertEquals(now, result.getPreviousValue());
    assertEquals(inFiveHours, result.getNewValue());
}
Also used : LocalTime(io.spine.time.LocalTime) Test(org.junit.Test)

Example 9 with LocalTime

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

the class LocalTimeStringifier method fromString.

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

Example 10 with LocalTime

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

the class OffsetTimesShould method add_minutes.

@Test
public void add_minutes() {
    final int minutesDelta = random(1, 300);
    final Duration deltaDuration = Durations2.minutes(minutesDelta);
    final Timestamp gmtFuture = Timestamps.add(gmtNow, deltaDuration);
    final LocalTime expectedFuture = LocalTimes.timeAt(gmtFuture, zoneOffset);
    final LocalTime actualFuture = addMinutes(now, minutesDelta).getTime();
    assertEquals(expectedFuture, actualFuture);
}
Also used : LocalTime(io.spine.time.LocalTime) Duration(com.google.protobuf.Duration) Timestamp(com.google.protobuf.Timestamp) Test(org.junit.Test) AbstractZonedTimeTest(io.spine.time.AbstractZonedTimeTest)

Aggregations

LocalTime (io.spine.time.LocalTime)19 Test (org.junit.Test)18 AbstractZonedTimeTest (io.spine.time.AbstractZonedTimeTest)10 Duration (com.google.protobuf.Duration)8 Timestamp (com.google.protobuf.Timestamp)8 LocalTimeChange (io.spine.time.change.LocalTimeChange)1 ParseException (java.text.ParseException)1 Calendar (java.util.Calendar)1