From d5976df21560a3ef03d667be4d1cb20cb832bf4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9trus=20Pradella?= Date: Thu, 18 Jul 2024 06:30:23 -0300 Subject: [PATCH] Add 'yyyy/MM/dd HH:mm:ss' as the default date formatter at FCTimeUtil --- .../br/com/finalcraft/evernifecore/util/FCTimeUtil.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/br/com/finalcraft/evernifecore/util/FCTimeUtil.java b/src/main/java/br/com/finalcraft/evernifecore/util/FCTimeUtil.java index 7d13a2cc..a13b0338 100644 --- a/src/main/java/br/com/finalcraft/evernifecore/util/FCTimeUtil.java +++ b/src/main/java/br/com/finalcraft/evernifecore/util/FCTimeUtil.java @@ -122,6 +122,8 @@ private static Long toMillis(long value, String type){ } } + public static final DateTimeFormatter FORMATTER_DEFAULT = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"); + public static final DateTimeFormatter FORMATTER_DATETIME = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm"); public static final DateTimeFormatter FORMATTER_DATETIME_ALT = DateTimeFormatter.ofPattern("yyyy/MM/dd'T'HH:mm"); public static final DateTimeFormatter FORMATTER_DATETIME_REVERSE = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"); @@ -166,9 +168,12 @@ public static LocalDateTime universalDateConverter(String dateString) { return Timestamp.valueOf(dateString).toLocalDateTime(); } - //Testar formato convencional yyyy-MM-dd'T'HH:mm if (dateString.charAt(4) == '/'){ - return LocalDateTime.parse(dateString, FORMATTER_DATETIME_ALT); + if (dateString.length() == 19){ + return LocalDateTime.parse(dateString, FORMATTER_DEFAULT); + }else { + return LocalDateTime.parse(dateString, FORMATTER_DATETIME_ALT); + } }else if (dateString.charAt(2) == '/'){ if (dateString.length() <= 16){ return LocalDateTime.parse(dateString, FORMATTER_DATETIME_REVERSE);