set seconds and milliseconds to zero

This commit is contained in:
Jörg Henke committed 2023-10-18 16:24:23 +02:00
1 parent 4f5db460ae
commit a737adf8c1
3 files changed
+3 -3

No files matched your search

@@ -30,7 +30,7 @@ public class TimeService {
} else {
offset = interval - compareMinute;
}
return givenTime.plusMinutes(offset);
return givenTime.plusMinutes(offset).withSecond(0).withNano(0);
}
}
}
@@ -17,7 +17,7 @@ public class TestTimeService {
@Test
public void testRoundTime() {
TimeService service = new TimeService();
LocalDateTime today = LocalDateTime.now();
LocalDateTime today = LocalDateTime.now().withSecond(0).withNano(0);
assertEquals("01:00", service.roundTime(today.withHour(1).withMinute(7), 15).format(DateTimeFormatter.ofPattern("HH:mm")));
assertEquals("01:15", service.roundTime(today.withHour(1).withMinute(8), 15).format(DateTimeFormatter.ofPattern("HH:mm")));
assertEquals("01:15", service.roundTime(today.withHour(1).withMinute(9), 15).format(DateTimeFormatter.ofPattern("HH:mm")));