marta-jankovics commented on code in PR #5864:
URL: https://github.com/apache/fineract/pull/5864#discussion_r3276012065
##########
fineract-core/src/main/java/org/apache/fineract/infrastructure/core/service/DateUtils.java:
##########
@@ -464,6 +464,36 @@ public static LocalDateTime
convertDateTimeStringToLocalDateTime(String dateTime
}
}
+ public static OffsetDateTime convertDateTimeStringToOffsetDateTime(String
dateTimeStr, String dateFormat, String localeStr,
+ LocalTime fallbackTime) {
+ if (dateTimeStr == null || dateTimeStr.isBlank()) {
+ return null;
+ }
+ final Locale locale = localeStr == null ? null :
JsonParserHelper.localeFromString(localeStr);
+ DateTimeFormatter formatter = getDateFormatter(dateFormat, locale);
+ TemporalAccessor parsed = formatter.parse(dateTimeStr);
+
+ boolean hasTime = parsed.isSupported(ChronoField.HOUR_OF_DAY) &&
parsed.isSupported(ChronoField.MINUTE_OF_HOUR);
+ boolean hasOffset = parsed.isSupported(ChronoField.OFFSET_SECONDS);
+
+ try {
+ if (hasTime && hasOffset) {
+ return OffsetDateTime.from(parsed);
+ } else if (hasTime) {
+ LocalDateTime localDateTime = LocalDateTime.from(parsed);
+ return
localDateTime.atOffset(OffsetDateTime.now().getOffset());
Review Comment:
Please use ZoneOffset.UTC getAuditZoneId() instead of now() everywhere
##########
fineract-core/src/main/java/org/apache/fineract/infrastructure/core/service/DateUtils.java:
##########
@@ -464,6 +464,36 @@ public static LocalDateTime
convertDateTimeStringToLocalDateTime(String dateTime
}
}
+ public static OffsetDateTime convertDateTimeStringToOffsetDateTime(String
dateTimeStr, String dateFormat, String localeStr,
+ LocalTime fallbackTime) {
+ if (dateTimeStr == null || dateTimeStr.isBlank()) {
+ return null;
+ }
+ final Locale locale = localeStr == null ? null :
JsonParserHelper.localeFromString(localeStr);
Review Comment:
Locale locale should be passed as parameter
##########
fineract-core/src/main/java/org/apache/fineract/infrastructure/core/service/DateUtils.java:
##########
@@ -464,6 +464,36 @@ public static LocalDateTime
convertDateTimeStringToLocalDateTime(String dateTime
}
}
+ public static OffsetDateTime convertDateTimeStringToOffsetDateTime(String
dateTimeStr, String dateFormat, String localeStr,
+ LocalTime fallbackTime) {
+ if (dateTimeStr == null || dateTimeStr.isBlank()) {
Review Comment:
minor: Strings.isEmpty(stringDateTime) is simpler
##########
fineract-core/src/main/java/org/apache/fineract/infrastructure/core/service/DateUtils.java:
##########
@@ -464,6 +464,36 @@ public static LocalDateTime
convertDateTimeStringToLocalDateTime(String dateTime
}
}
+ public static OffsetDateTime convertDateTimeStringToOffsetDateTime(String
dateTimeStr, String dateFormat, String localeStr,
Review Comment:
If we follow the naming convention in this utility parseOffsetDateTime would
be consequent.
There are other parseOffsetDateTime methods, could you please move this next
to them?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]