Mostly revert the timestamp muddling done by the prior commit
My prior attempt to fix the timestamp issues I was seeing was
horribly misguided and wrong.
The Timestamp objects have the correct time from the epoch; its
the toString() method that is applying the JVM's time zone to them.
I need to fix the formatter in gwtjsonrpc to format in UTC rather
than assuming toString() will put out a UTC string.
Signed-off-by: Shawn O. Pearce <sop@google.com>
diff --git a/src/main/java/com/google/gwtorm/schema/sql/SqlTimestampTypeInfo.java b/src/main/java/com/google/gwtorm/schema/sql/SqlTimestampTypeInfo.java
index d97b227..9a71ad3 100644
--- a/src/main/java/com/google/gwtorm/schema/sql/SqlTimestampTypeInfo.java
+++ b/src/main/java/com/google/gwtorm/schema/sql/SqlTimestampTypeInfo.java
@@ -14,40 +14,11 @@
package com.google.gwtorm.schema.sql;
-import com.google.gwtorm.jdbc.gen.CodeGenSupport;
import com.google.gwtorm.schema.ColumnModel;
-import org.objectweb.asm.Opcodes;
-import org.objectweb.asm.Type;
-
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Timestamp;
import java.sql.Types;
-import java.util.Calendar;
-import java.util.TimeZone;
public class SqlTimestampTypeInfo extends SqlTypeInfo {
- private static final TimeZone UTC = TimeZone.getTimeZone("UTC");
-
- public static void setAsUTC(final PreparedStatement ps, final int col,
- final Timestamp val) throws SQLException {
- ps.setTimestamp(col, val, Calendar.getInstance(UTC));
- }
-
- public static Timestamp getAsUTC(final ResultSet rs, final int col)
- throws SQLException {
- Timestamp s = rs.getTimestamp(col);
- if (s != null) {
- final int o = s.getTimezoneOffset();
- if (o != 0) {
- s = new Timestamp(s.getTime() + (o * 60 * 1000L));
- }
- }
- return s;
- }
-
@Override
protected String getJavaSqlTypeAlias() {
return "Timestamp";
@@ -59,31 +30,6 @@
}
@Override
- public void generateResultSetGet(CodeGenSupport cgs) {
- final Type typeCalendar = Type.getType(java.util.Calendar.class);
- cgs.fieldSetBegin();
- cgs.pushSqlHandle();
- cgs.pushColumnIndex();
- cgs.mv.visitMethodInsn(Opcodes.INVOKESTATIC, Type.getType(
- SqlTimestampTypeInfo.class).getInternalName(), "getAsUTC", Type
- .getMethodDescriptor(Type.getType(Timestamp.class), new Type[] {
- Type.getType(ResultSet.class), Type.INT_TYPE}));
- cgs.fieldSetEnd();
- }
-
- @Override
- public void generatePreparedStatementSet(final CodeGenSupport cgs) {
- cgs.pushSqlHandle();
- cgs.pushColumnIndex();
- cgs.pushFieldValue();
- cgs.mv.visitMethodInsn(Opcodes.INVOKESTATIC, Type.getType(
- SqlTimestampTypeInfo.class).getInternalName(), "setAsUTC", Type
- .getMethodDescriptor(Type.VOID_TYPE, new Type[] {
- Type.getType(PreparedStatement.class), Type.INT_TYPE,
- Type.getType(Timestamp.class)}));
- }
-
- @Override
public String getSqlType(final ColumnModel col, final SqlDialect dialect) {
final StringBuilder r = new StringBuilder();
r.append(dialect.getSqlTypeName(getSqlTypeConstant()));