Done ticket GEPAFINBE-39
This commit is contained in:
@@ -92,4 +92,20 @@ public class DateTimeUtil {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
|
||||
return LocalDateTime.parse(dateTimeStr, formatter);
|
||||
}
|
||||
|
||||
public static String parseLocalTimeToString(LocalTime time, String format) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format);
|
||||
return time.format(formatter);
|
||||
}
|
||||
|
||||
// Method 2: Convert String and format to LocalTime
|
||||
public static LocalTime parseStringToLocalTime(String timeString, String format) {
|
||||
try {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format);
|
||||
return LocalTime.parse(timeString, formatter);
|
||||
} catch (DateTimeParseException e) {
|
||||
System.out.println("Invalid time format: " + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user