Done ticket GEPAFINBE-219
This commit is contained in:
@@ -98,11 +98,19 @@ public class DateTimeUtil {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
|
||||
return LocalDateTime.parse(dateTimeStr, formatter);
|
||||
}
|
||||
public static LocalDateTime parseStringToLocalDateTime(String timestampStr) {
|
||||
// Use ISO_LOCAL_DATE_TIME to parse the input string
|
||||
return LocalDateTime.parse(timestampStr, DateTimeFormatter.ISO_LOCAL_DATE_TIME);
|
||||
public static LocalDateTime parseStringToLocalDateTime(String dateStr) {
|
||||
if (dateStr == null || dateStr.isEmpty()) return null;
|
||||
|
||||
try {
|
||||
return LocalDateTime.parse(dateStr, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
return LocalDateTime.parse(dateStr, DateTimeFormatter.ISO_DATE_TIME); // fallback
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String parseLocalTimeToString(LocalTime time, String format) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format);
|
||||
return time.format(formatter);
|
||||
|
||||
Reference in New Issue
Block a user