File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed
src/main/java/com/example/wini/domain/member/dto/common Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change 11package com .example .wini .domain .member .dto .common ;
22
3+ import static com .example .wini .global .common .constant .StatusReserveTimeConstants .INDEFINITE_HOUR ;
4+ import static com .example .wini .global .common .constant .StatusReserveTimeConstants .INDEFINITE_MINUTE ;
5+ import static com .example .wini .global .common .constant .StatusReserveTimeConstants .INDEFINITE_SECONDS ;
6+ import static com .example .wini .global .common .constant .StatusReserveTimeConstants .SECONDS_PER_HOUR ;
7+ import static com .example .wini .global .common .constant .StatusReserveTimeConstants .SECONDS_PER_MINUTE ;
8+
39import jakarta .validation .constraints .Max ;
410import jakarta .validation .constraints .Min ;
511import jakarta .validation .constraints .NotNull ;
6- import java .time .Duration ;
712
813public record ReservedTimeInfo (
914 @ NotNull @ Min (value = -1 ) @ Max (value = 12 ) Long hour , @ NotNull @ Min (value = -1 ) @ Max (value = 59 ) Long minute ) {
1015 public static ReservedTimeInfo of (long hour , long minute ) {
1116 return new ReservedTimeInfo (hour , minute );
1217 }
1318
14- public Duration toDuration () {
15- if (this .hour == - 1 && this .minute == - 1 ) {
16- return Duration . ofDays ( 365L * 100 ) ;
19+ public long toSeconds () {
20+ if (this .hour == INDEFINITE_HOUR && this .minute == INDEFINITE_MINUTE ) {
21+ return INDEFINITE_SECONDS ;
1722 }
18-
19- return Duration .ofHours (this .hour ).plusMinutes (this .minute );
23+ return this .hour * SECONDS_PER_HOUR + this .minute * SECONDS_PER_MINUTE ;
2024 }
2125}
You can’t perform that action at this time.
0 commit comments