Merge pull request #2708 from FOCONIS/fix-localtime

Part 1: Fix read/write/query LocalTime values
This commit is contained in:
Rob Bygrave authored and GitHub committed 2022-06-09 12:00:06 +12:00
commit c02ab7340c
6 files changed
+105 -9

No files matched your search

@@ -13,11 +13,10 @@ public interface DataTimeZone {
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.
* Return the Calendar to use for Timezone information when reading/writing a time component (date only/time only).
* A time component has normally no timezone information, but some platforms (like MySQL) reqire this.
*/
default Calendar getDateTimeZone() {
default Calendar getTimeComponentTimeZone() {
return null;
}
}
@@ -19,7 +19,7 @@ public class MySqlDataTimeZone implements DataTimeZone {
}
@Override
public Calendar getDateTimeZone() {
public Calendar getTimeComponentTimeZone() {
return zone;
}
}
@@ -158,7 +158,7 @@ public class DataBind implements DataBinder {
@Override
public final void setDate(java.sql.Date v) throws SQLException {
Calendar timeZone = dataTimeZone.getDateTimeZone();
Calendar timeZone = dataTimeZone.getTimeComponentTimeZone();
if (timeZone != null) {
pstmt.setDate(++pos, v, timeZone);
} else {
@@ -178,7 +178,7 @@ public class DataBind implements DataBinder {
@Override
public final void setTime(Time v) throws SQLException {
Calendar timeZone = dataTimeZone.getTimeZone();
Calendar timeZone = dataTimeZone.getTimeComponentTimeZone();
if (timeZone != null) {
pstmt.setTime(++pos, v, timeZone);
} else {
@@ -107,7 +107,7 @@ public class RsetDataReader implements DataReader {
@Override
public final Date getDate() throws SQLException {
Calendar cal = dataTimeZone.getDateTimeZone();
Calendar cal = dataTimeZone.getTimeComponentTimeZone();
if (cal != null) {
return rset.getDate(pos(), cal);
} else {
@@ -156,7 +156,7 @@ public class RsetDataReader implements DataReader {
@Override
public final Time getTime() throws SQLException {
Calendar cal = dataTimeZone.getTimeZone();
Calendar cal = dataTimeZone.getTimeComponentTimeZone();
if (cal != null) {
return rset.getTime(pos(), cal);
} else {