set seconds and milliseconds to zero

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

View File

@ -7,7 +7,7 @@ plugins {
apply plugin: 'io.spring.dependency-management'
group = 'de.jottyfan'
version = '1.3.7'
version = '1.3.8'
description = """timetrack"""

View File

@ -30,7 +30,7 @@ public class TimeService {
} else {
offset = interval - compareMinute;
}
return givenTime.plusMinutes(offset);
return givenTime.plusMinutes(offset).withSecond(0).withNano(0);
}
}
}

View File

@ -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")));