Merge pull request #563 from mohitsinha/develop

JdbcSupport added utility function for getting localDateTime after considering timezone of tenant
This commit is contained in:
Awasum Yannick
2019-07-07 20:09:17 +01:00
committed by GitHub
@@ -29,6 +29,8 @@ import org.joda.time.LocalDate;
import org.joda.time.LocalTime;
import org.springframework.jdbc.support.JdbcUtils;
import static org.apache.fineract.infrastructure.core.service.DateUtils.getDateTimeZoneOfTenant;
/**
* Support for retrieving possibly null values from jdbc recordset delegating to
* springs {@link JdbcUtils} where possible.
@@ -44,6 +46,15 @@ public class JdbcSupport {
return dateTime;
}
public static DateTime getLocalDateTime(final ResultSet rs, final String columnName) throws SQLException {
DateTime dateTime = null;
final Timestamp dateValue = rs.getTimestamp(columnName);
if (dateValue != null) {
dateTime = new DateTime(dateValue.getTime()).withZone(getDateTimeZoneOfTenant());
}
return dateTime;
}
public static LocalDate getLocalDate(final ResultSet rs, final String columnName) throws SQLException {
LocalDate localDate = null;
final Date dateValue = rs.getDate(columnName);