diff --git a/src/main/java/com/gongspot/project/domain/place/converter/PlaceConverter.java b/src/main/java/com/gongspot/project/domain/place/converter/PlaceConverter.java index 9cb15dc..ba0d543 100644 --- a/src/main/java/com/gongspot/project/domain/place/converter/PlaceConverter.java +++ b/src/main/java/com/gongspot/project/domain/place/converter/PlaceConverter.java @@ -24,8 +24,8 @@ public static PlaceResponseDTO.GetPlaceDTO toGetPlaceDTO(Place place, Double rat .nickname(review.getUser().getNickname()) .profileImageUrl(review.getUser().getProfileImg()) .congestion(mapCongestionToString(review.getCongestion())) - .daytime(toRelativeDaytime(review.getDatetime())) - .datetime(toRelativeDateString(review.getDatetime())) + .daytime(review.getDatetime().format(DateTimeFormatter.ofPattern("M/d"))) + .datetime(review.getDatetime().format(DateTimeFormatter.ofPattern("HH:mm"))) .build()) .toList(); @@ -43,37 +43,6 @@ public static PlaceResponseDTO.GetPlaceDTO toGetPlaceDTO(Place place, Double rat .congestionList(congestionDTOS) .build(); } - private static String toRelativeDaytime(LocalDateTime dateTime) { - long days = Duration.between(dateTime.toLocalDate().atStartOfDay(), LocalDateTime.now().toLocalDate().atStartOfDay()).toDays(); - - if (days == 0) return "오늘"; - else if (days > 0 && days < 4) return days + "일 전"; - else { - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("M/d"); - return dateTime.format(formatter); - } - } - - private static String toRelativeDateString(LocalDateTime dateTime) { - LocalDateTime now = LocalDateTime.now(); - - Duration duration = Duration.between(dateTime,now); - - long minutes = duration.toMinutes(); - long hours = duration.toHours(); - - if (minutes < 60) { - return minutes + "분 전"; - } else if (hours < 2) { - return "1시간 전"; - } else if (hours < 3) { - return "2시간 전"; - } else if (hours < 4) { - return "3시간 전"; - }else { - return dateTime.format(DateTimeFormatter.ofPattern("HH:mm")); - } - } private static String mapCongestionToString(CongestionEnum congestion) { if (congestion == null) { diff --git a/src/main/java/com/gongspot/project/domain/review/converter/ReviewConverter.java b/src/main/java/com/gongspot/project/domain/review/converter/ReviewConverter.java index b0dfc59..c3a5021 100644 --- a/src/main/java/com/gongspot/project/domain/review/converter/ReviewConverter.java +++ b/src/main/java/com/gongspot/project/domain/review/converter/ReviewConverter.java @@ -34,7 +34,7 @@ public static ReviewResponseDTO.GetReviewDTO toGetReviewDTO(Review review, List< .userId(review.getUser().getId()) .nickname(review.getUser().getNickname()) .profileImageUrl(review.getUser().getProfileImg()) - .datetime(review.getCreatedAt().format(DateTimeFormatter.ofPattern("yy.MM.dd"))) + .datetime(review.getDatetime().format(DateTimeFormatter.ofPattern("yy.MM.dd"))) .rating(review.getRating()) .reviewImageUrl(imageUrls) .content(review.getContent()) @@ -49,8 +49,8 @@ private static ReviewResponseDTO.CongestionItemDTO toCongestionItemDTO(Review re .nickname(review.getUser().getNickname()) .profileImageUrl(review.getUser().getProfileImg()) .congestion(mapCongestionToString(review.getCongestion())) - .daytime(toRelativeDaytime(review.getDatetime())) - .datetime(toRelativeDateString(review.getDatetime())) + .daytime(review.getDatetime().format(DateTimeFormatter.ofPattern("M/d"))) + .datetime(review.getDatetime().format(DateTimeFormatter.ofPattern("HH:mm"))) .paid(paidStatus) .build(); } @@ -202,37 +202,7 @@ private static String mapCongestionToString(CongestionEnum congestion) { } } - private static String toRelativeDaytime(LocalDateTime dateTime) { - long days = Duration.between(dateTime.toLocalDate().atStartOfDay(), LocalDateTime.now().toLocalDate().atStartOfDay()).toDays(); - if (days == 0) return "오늘"; - else if (days > 0 && days < 4) return days + "일 전"; - else { - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("M/d"); - return dateTime.format(formatter); - } - } - - private static String toRelativeDateString(LocalDateTime dateTime) { - LocalDateTime now = LocalDateTime.now(); - - Duration duration = Duration.between(dateTime,now); - - long minutes = duration.toMinutes(); - long hours = duration.toHours(); - - if (minutes < 60) { - return minutes + "분 전"; - } else if (hours < 2) { - return "1시간 전"; - } else if (hours < 3) { - return "2시간 전"; - } else if (hours < 4) { - return "3시간 전"; - }else { - return dateTime.format(DateTimeFormatter.ofPattern("HH:mm")); - } - } private static String toDateString(LocalDate dateTime) { String dayOfWeek; switch (dateTime.getDayOfWeek()) {