Fix OffsetDateTime fetch from DB

This commit is contained in:
Adam Saghy
2022-08-04 14:23:59 +02:00
committed by Arnold Gálovics
parent 69083de949
commit 79180506b6
@@ -27,7 +27,6 @@ import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.LocalTime; import java.time.LocalTime;
import java.time.OffsetDateTime; import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import org.apache.fineract.infrastructure.core.service.DateUtils; import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.springframework.jdbc.support.JdbcUtils; import org.springframework.jdbc.support.JdbcUtils;
@@ -139,7 +138,8 @@ public final class JdbcSupport {
public static OffsetDateTime getOffsetDateTime(ResultSet rs, String columnName) throws SQLException { public static OffsetDateTime getOffsetDateTime(ResultSet rs, String columnName) throws SQLException {
final Timestamp timestamp = rs.getTimestamp(columnName); final Timestamp timestamp = rs.getTimestamp(columnName);
if (timestamp != null) { if (timestamp != null) {
OffsetDateTime offsetDateTimeAtUTC = OffsetDateTime.of(timestamp.toLocalDateTime(), ZoneOffset.UTC); OffsetDateTime offsetDateTimeAtUTC = OffsetDateTime.of(timestamp.toLocalDateTime(),
DateUtils.getSystemZoneId().getRules().getOffset(timestamp.toLocalDateTime()));
return offsetDateTimeAtUTC return offsetDateTimeAtUTC
.withOffsetSameInstant(DateUtils.getDateTimeZoneOfTenant().getRules().getOffset(offsetDateTimeAtUTC.toInstant())); .withOffsetSameInstant(DateUtils.getDateTimeZoneOfTenant().getRules().getOffset(offsetDateTimeAtUTC.toInstant()));
} }