FIX: Regression of #1775 - set date for other platfroms broken, when ebean.dataTimeZone is set to GMT

This commit is contained in:
Roland Praml
2020-02-01 15:59:18 +13:00
committed by rob bygrave
parent 13f8da6b2e
commit f161a38334
6 changed files with 32 additions and 3 deletions
@@ -8,7 +8,16 @@ import java.util.Calendar;
public interface DataTimeZone {
/**
* Return the Calendar to use for Timezone information.
* Return the Calendar to use for Timezone information when reading/writing timestamps.
*/
Calendar getTimeZone();
/**
* Return the Calendar to use for Timezone information when reading/writing date.
* A 'date' only value has normally no timezone information, but some platforms (like MySQL)
* reqire this.
*/
default Calendar getDateTimeZone() {
return null;
}
}
@@ -17,4 +17,9 @@ public class LocalDataTimeZone implements DataTimeZone {
public Calendar getTimeZone() {
return zone;
}
@Override
public Calendar getDateTimeZone() {
return zone; // workaround for MySQL. TODO: rename class to MySqlDataTimeZone!?
}
}
@@ -141,7 +141,7 @@ public class DataBind {
}
public void setDate(java.sql.Date v) throws SQLException {
Calendar timeZone = dataTimeZone.getTimeZone();
Calendar timeZone = dataTimeZone.getDateTimeZone();
if (timeZone != null) {
pstmt.setDate(++pos, v, timeZone);
} else {
@@ -106,7 +106,7 @@ public class RsetDataReader implements DataReader {
@Override
public Date getDate() throws SQLException {
Calendar cal = dataTimeZone.getTimeZone();
Calendar cal = dataTimeZone.getDateTimeZone();
if (cal != null) {
return rset.getDate(pos(), cal);
} else {