galovics commented on code in PR #2446:
URL: https://github.com/apache/fineract/pull/2446#discussion_r929059819
##########
fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/service/GenericDataServiceImpl.java:
##########
@@ -160,23 +161,32 @@ public String generateJsonFromGenericResultsetData(final
GenericResultsetData gr
if (currColType == null && colType.equalsIgnoreCase("DATE")) {
currColType = "DATE";
}
+ if (currColType == null &&
colType.equalsIgnoreCase("DATETIME")) {
+ currColType = "DATETIME";
+ }
currVal = row.get(j);
if (currVal != null && currColType != null) {
if (currColType.equals("DECIMAL") ||
currColType.equals("INTEGER")) {
writer.append(currVal);
} else {
if (currColType.equals("DATE")) {
- final LocalDate localDate =
LocalDate.parse(currVal);
+ final LocalDate localDate =
LocalDate.parse(currVal.toString());
writer.append(
"[" + localDate.getYear() + ", " +
localDate.getMonthValue() + ", " + localDate.getDayOfMonth() + "]");
} else if (currColType.equals("DATETIME")) {
- final LocalDateTime localDateTime =
LocalDateTime.parse(formatDateTimeValue(currVal),
- DateUtils.DEFAULT_DATETIME_FORMATER);
- writer.append("[" + localDateTime.getYear() + ", "
+ localDateTime.getMonthValue() + ", "
- + localDateTime.getDayOfMonth() + ", " +
localDateTime.getHour() + ", " + localDateTime.getMinute()
- + ", " + localDateTime.getSecond() + ", "
+ localDateTime.get(ChronoField.MILLI_OF_SECOND) + "]");
+ Calendar dateVal = Calendar.getInstance();
+ if (currVal instanceof Date) {
+ dateVal.setTime((Date) currVal);
+ } else if (currVal instanceof LocalDateTime) {
+ dateVal.setTime(
+ Date.from(((LocalDateTime)
currVal).atZone(DateUtils.getDateTimeZoneOfTenant()).toInstant()));
Review Comment:
I think you misunderstood it Alberto.
The only thing I'm saying is about the TimeZone.
If we're saving the datetime value into the DB with TimeZoneX and reading it
back and converting it to TimeZoneY, that's definitely not good cause we're
messing up the offsets.
--
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]