diff --git a/doorip-api/src/main/java/org/doorip/trip/dto/response/TripCreateResponse.java b/doorip-api/src/main/java/org/doorip/trip/dto/response/TripCreateResponse.java index 0683362..31f7587 100644 --- a/doorip-api/src/main/java/org/doorip/trip/dto/response/TripCreateResponse.java +++ b/doorip-api/src/main/java/org/doorip/trip/dto/response/TripCreateResponse.java @@ -1,12 +1,14 @@ package org.doorip.trip.dto.response; import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.AccessLevel; +import lombok.Builder; import org.doorip.trip.domain.Trip; import java.time.LocalDate; +import java.time.temporal.ChronoUnit; -import static java.time.Period.between; - +@Builder(access = AccessLevel.PRIVATE) public record TripCreateResponse( Long tripId, String title, @@ -19,13 +21,13 @@ public record TripCreateResponse( ) { public static TripCreateResponse of(Trip trip) { - return new TripCreateResponse( - trip.getId(), - trip.getTitle(), - trip.getStartDate(), - trip.getEndDate(), - trip.getCode(), - between(LocalDate.now(), trip.getStartDate()).getDays() - ); + return TripCreateResponse.builder() + .tripId(trip.getId()) + .title(trip.getTitle()) + .startDate(trip.getStartDate()) + .endDate(trip.getEndDate()) + .code(trip.getCode()) + .day((int) ChronoUnit.DAYS.between(LocalDate.now(), trip.getStartDate())) + .build(); } } diff --git a/doorip-api/src/main/java/org/doorip/trip/dto/response/TripResponse.java b/doorip-api/src/main/java/org/doorip/trip/dto/response/TripResponse.java index 25779ae..2fe2080 100644 --- a/doorip-api/src/main/java/org/doorip/trip/dto/response/TripResponse.java +++ b/doorip-api/src/main/java/org/doorip/trip/dto/response/TripResponse.java @@ -6,8 +6,7 @@ import org.doorip.trip.domain.Trip; import java.time.LocalDate; - -import static java.time.Period.between; +import java.time.temporal.ChronoUnit; @Builder(access = AccessLevel.PRIVATE) public record TripResponse( @@ -25,7 +24,7 @@ public static TripResponse of(Trip trip) { .title(trip.getTitle()) .startDate(trip.getStartDate()) .endDate(trip.getEndDate()) - .day(between(LocalDate.now(), trip.getStartDate()).getDays()) + .day((int) ChronoUnit.DAYS.between(LocalDate.now(), trip.getStartDate())) .build(); } }