}
else
{
- df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
+ //if type is timestamptz then data is in GMT, else it is in local timezone
+ if (fields[columnIndex - 1].getPGType().equals("timestamptz")) {
+ sbuf.append(" GMT");
+ df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS z");
+ } else {
+ df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
+ }
}
}
else if (slen == 19)
{
// No tz or fractional second info.
- // I'm not sure if it is
- // possible to have a string in this format, as pg
- // should give us tz qualified timestamps back, but it was
- // in the old code, so I'm handling it for now.
+ // if type is timestamptz then data is in GMT, else it is in local timezone
+ if (fields[columnIndex - 1].getPGType().equals("timestamptz")) {
+ sbuf.append(" GMT");
+ df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
+ } else {
df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ }
}
else
{
retVal = new Timestamp[ count ];
StringBuffer sbuf = null;
for ( ; count > 0; count-- )
- ((java.sql.Timestamp[])retVal)[i++] = ResultSet.toTimestamp( arrayContents[(int)index++], rs );
+ ((java.sql.Timestamp[])retVal)[i++] = ResultSet.toTimestamp( arrayContents[(int)index++], rs, getBaseTypeName() );
break;
// Other datatypes not currently supported. If you are really using other types ask
*/
public Timestamp getTimestamp(int columnIndex) throws SQLException
{
- return toTimestamp( getString(columnIndex), this );
+ return toTimestamp( getString(columnIndex), this, fields[columnIndex-1].getPGType() );
}
/*
*
* @throws SQLException if there is a problem parsing s.
**/
- public static Timestamp toTimestamp(String s, ResultSet resultSet)
+ public static Timestamp toTimestamp(String s, ResultSet resultSet, String pgDataType)
throws SQLException
{
if (s == null)
}
else
{
- // Just found fractional seconds but no timezone.
+ // Just found fractional seconds but no timezone.
+ //If timestamptz then we use GMT, else local timezone
+ if (pgDataType.equals("timestamptz")) {
+ resultSet.sbuf.append(" GMT");
+ df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS z");
+ } else {
df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
+ }
}
}
else if (slen == 19)
{
- // No tz or fractional second info.
- // I'm not sure if it is
- // possible to have a string in this format, as pg
- // should give us tz qualified timestamps back, but it was
- // in the old code, so I'm handling it for now.
+ // No tz or fractional second info.
+ //If timestamptz then we use GMT, else local timezone
+ if (pgDataType.equals("timestamptz")) {
+ resultSet.sbuf.append(" GMT");
+ df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
+ } else {
df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ }
}
else
{