From 962dc7c49895cf726147c5667570bcc63583d9f8 Mon Sep 17 00:00:00 2001 From: sunwoong Date: Thu, 11 Jan 2024 22:29:24 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=82=A0=EC=A7=9C=20=EC=98=A4=EB=A5=98?= =?UTF-8?q?=20=ED=95=B4=EA=B2=B0=20(#74)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../trip/dto/response/TripCreateResponse.java | 22 ++++++++++--------- .../trip/dto/response/TripResponse.java | 5 ++--- 2 files changed, 14 insertions(+), 13 deletions(-) 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(); } }