From 65948b18de3f134ffd8c2627f3d1aa61b1f1dcbe Mon Sep 17 00:00:00 2001 From: "Jonguk. Lim" Date: Wed, 25 Sep 2024 11:37:38 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=B9=B4=EC=B9=B4=EC=98=A4=ED=86=A1=20?= =?UTF-8?q?=EC=9E=AC=EC=97=B4=EB=9E=8C=20=EB=A7=8C=EB=A3=8C=EC=8B=9C?= =?UTF-8?q?=EA=B0=84=20=EC=84=A4=EC=A0=95=20=EB=B0=98=EC=98=81=20=20=20=20?= =?UTF-8?q?=20=20=EC=B5=9C=EC=B4=88=EC=97=B4=EB=9E=8C=EB=A7=88=EA=B0=90?= =?UTF-8?q?=EC=8B=9C=EA=B0=84=20+=201=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../support/accept/AcptDocKkoTalk.java | 8 +- .../cokr/xit/ens/core/utils/DateUtil.java | 132 ++++++++++++++++++ 2 files changed, 135 insertions(+), 5 deletions(-) diff --git a/src/main/java/cokr/xit/ens/biz/iup/signtalk/service/support/accept/AcptDocKkoTalk.java b/src/main/java/cokr/xit/ens/biz/iup/signtalk/service/support/accept/AcptDocKkoTalk.java index c4de311..6996269 100644 --- a/src/main/java/cokr/xit/ens/biz/iup/signtalk/service/support/accept/AcptDocKkoTalk.java +++ b/src/main/java/cokr/xit/ens/biz/iup/signtalk/service/support/accept/AcptDocKkoTalk.java @@ -15,17 +15,15 @@ public class AcptDocKkoTalk implements Accept { @Override public KkotalkApiDTO.Envelope createDocument() { + final String readExpiresAt = DateUtil.getTimeTOfTime(tbInputDataXit.getTbInputXit().getPayExpiresDt().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))); return KkotalkApiDTO.Envelope.builder() .hash(null) .content( KkotalkApiDTO.Content.builder() .link(redirectUrl) .build()) - .readExpiresAt( - DateUtil.getTimeTOfTime(tbInputDataXit.getTbInputXit().getPayExpiresDt().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")))) - // FIXME: readExpiresAt + 1일로 설정 - .reviewExpiresAt( - "2024-10-30T23:59:59") + .readExpiresAt(readExpiresAt) + .reviewExpiresAt(DateUtil.getAddDayT(readExpiresAt, 1)) .build(); } } diff --git a/src/main/java/cokr/xit/ens/core/utils/DateUtil.java b/src/main/java/cokr/xit/ens/core/utils/DateUtil.java index 3cbe72d..8e9636d 100644 --- a/src/main/java/cokr/xit/ens/core/utils/DateUtil.java +++ b/src/main/java/cokr/xit/ens/core/utils/DateUtil.java @@ -459,4 +459,136 @@ public class DateUtil { public static LocalDateTime localDateTime() { return LocalDateTime.now(); } + + /** + *
+     * 지난 날짜 확인 : 2020-06-22T23:20:32 ISO 시간 표기법에 따라 'T'를 꼭 붙여야 함.
+     * sourceDate > compareDate = true
+     * sourceDate < compareDate = false
+     * sourceDate == compareDate = false
+     *
+     * @param sourceDate  시작 년-월-일
+     * @param compareDate 비교 년-월-일
+     * @return boolean
+     * 
+ */ + public static boolean isAfterLocalDateTimeT(final String sourceDate, final String compareDate) { + boolean result = false; + + try { + LocalDateTime source = parseLocalDateTime(sourceDate); + result = source.isAfter(parseLocalDateTime(compareDate)); + } catch (Exception e) { + log.error("DateUtils::isAfterLocalDate", e); + } + + return result; + } + + /** + *
+     * 날자 add : 2020-06-22T23:20:32
+     * 빼기는 음수를 붙여서 넘기면 된다.
+     * ex : -1 = 빼기 1
+     *
+     * @param targetDate 계산할 년-월-일
+     * @param day        계산할 일
+     * @return String
+     * 
+ */ + public static String getAddDayT(final String targetDate, final int day) { + return getCalculatorDateAndTime(targetDate, 0, 0, day, 0, 0, 0); + } + + /** + * LocalDate.parse 객체 반환 + * + * @param target yyyy-MM-dd + * @return LocalDate.parse(tartget); + */ + public static LocalDate parseLocalDate(final String target) { + return LocalDate.parse(target); + } + + /** + * LocalDateTime.parse 객체 반환 + * + * @param target yyyy-MM-dd HH:mm:ss + * @return LocalDateTime.parse(tartget); + */ + public static LocalDateTime parseLocalDateTime(final String target) { + return LocalDateTime.parse(target); + } + + /** + *
+     * 년 월 일 계산
+     * 날짜만 계산 년-월-일 형태로 넘겨줘야함(안그럼 예외)
+     * 해당월에 존재하지 않는 일을 넘겨도 예외
+     * 빼기는 음수를 붙여서 넘기면 된다.
+     * ex : -1 = 빼기 1
+     *
+     * @param targetDate 계산할 년-월-일
+     * @param year       계산할 년
+     * @param month      계산할 월
+     * @param day        계산할 일
+     * @return String
+     * 
+ */ + public static String getCalculatorDate(final String targetDate, final int year, final int month, final int day) { + String result = ""; + + try { + LocalDate localDate = parseLocalDate(targetDate); + localDate = localDate.plusYears(year); + localDate = localDate.plusMonths(month); + localDate = localDate.plusDays(day); + result = localDate.toString(); + } catch (Exception e) { + log.error("DateUtils::getCalculatorDate", e); + } + + return result; + } + + /** + *
+     * 날짜&시간 계산 년-월-일THH:mm:ss 형태(안그럼 예외)
+     * 2020-06-22T23:20:32 ISO 시간 표기법에 따라 'T'를 꼭 붙여야 함.
+     * 빼기는 음수를 붙여서 ex : -1 = 빼기 1
+     *
+     * @param targetDate 계산할 년-월-일T시:분:초
+     * @param year       계산할 년
+     * @param month      계산할 월
+     * @param day        계산할 일
+     * @param hour       계산할 시간
+     * @param minute     계산할 분
+     * @param second     계산할 초
+     * @return String
+     * 
+ */ + public static String getCalculatorDateAndTime(final String targetDate, final int year, final int month, final int day, int hour, int minute, int second) { + String result = ""; + + try { + LocalDateTime localDateTime = parseLocalDateTime(targetDate); + localDateTime = localDateTime.plusYears(year); + localDateTime = localDateTime.plusMonths(month); + localDateTime = localDateTime.plusDays(day); + localDateTime = localDateTime.plusHours(hour); + localDateTime = localDateTime.plusMinutes(minute); + localDateTime = localDateTime.plusSeconds(second); + result = localDateTime.toString(); + } catch (Exception e) { + log.error("DateUtils::getCalculatorDateAndTime", e); + } + + return result; + } + + public static void main(String[] args) { + System.out.println(getAddDayT("2024-10-30T23:59:59", 1)); + System.out.println(isAfterLocalDateTimeT("2024-10-30T23:59:59", "2024-10-30T23:59:58")); + System.out.println(isAfterLocalDateTimeT("2024-10-31T23:59:59", "2024-10-30T23:59:58")); + } }