Skip to content

Commit

Permalink
Add 'yyyy/MM/dd HH:mm:ss' as the default date formatter at FCTimeUtil
Browse files Browse the repository at this point in the history
  • Loading branch information
EverNife committed Jul 18, 2024
1 parent 3b57824 commit d5976df
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit d5976df

Please sign in to comment.