JdbcSupport added utility function for getting localDateTime after considering the timezone of the tenant.

This commit is contained in:
Mohit Sinha
2019-04-23 23:46:32 +07:00
parent 67ba10fc2e
commit aab294f4a8
@@ -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);