diff options
author | monica.dionisio <monica.dionisio@sonyericsson.com> | 2011-03-03 14:08:59 -0300 |
---|---|---|
committer | Ulrik Sjölin <ulrik.sjolin@sonyericsson.com> | 2011-05-09 15:48:04 +0200 |
commit | d2da19ef437920caa771751c431539d3ff2fc07a (patch) | |
tree | b01056bbede0e0300cfd11549617a6c638068e6e | |
parent | 8b7b1f49377f545666ea83805643a01d8ff164a5 (diff) | |
download | gwtjsonrpc-d2da19ef437920caa771751c431539d3ff2fc07a.tar.gz |
Timestamp deserializer bug fix
SqlTimestampDeserializer deserialize method parsed timestamp string
using java.text.SimpleDateFormat. This made a timestamp value to be
misunderstood.
To fix this issue SqlTimestampDeserializer was modified to call
JavaSqlTimestamp_JsonSerializer.parseTimestamp.
Bug: issue 850
Change-Id: I83fa5f78500feb2f782412f58c8c0d4a57c11b90
-rw-r--r-- | src/main/java/com/google/gwtjsonrpc/client/impl/ser/JavaSqlTimestamp_JsonSerializer.java | 2 | ||||
-rw-r--r-- | src/main/java/com/google/gwtjsonrpc/server/SqlTimestampDeserializer.java | 10 |
2 files changed, 4 insertions, 8 deletions
diff --git a/src/main/java/com/google/gwtjsonrpc/client/impl/ser/JavaSqlTimestamp_JsonSerializer.java b/src/main/java/com/google/gwtjsonrpc/client/impl/ser/JavaSqlTimestamp_JsonSerializer.java index dbf95b4..6c9ee35 100644 --- a/src/main/java/com/google/gwtjsonrpc/client/impl/ser/JavaSqlTimestamp_JsonSerializer.java +++ b/src/main/java/com/google/gwtjsonrpc/client/impl/ser/JavaSqlTimestamp_JsonSerializer.java @@ -76,7 +76,7 @@ public final class JavaSqlTimestamp_JsonSerializer extends }-*/; @SuppressWarnings("deprecation") - private static java.sql.Timestamp parseTimestamp(final String s) { + public static java.sql.Timestamp parseTimestamp(final String s) { final String[] components = s.split(" "); if (components.length != 2) { throw new IllegalArgumentException("Invalid escape format: " + s); diff --git a/src/main/java/com/google/gwtjsonrpc/server/SqlTimestampDeserializer.java b/src/main/java/com/google/gwtjsonrpc/server/SqlTimestampDeserializer.java index 10df038..4c2b348 100644 --- a/src/main/java/com/google/gwtjsonrpc/server/SqlTimestampDeserializer.java +++ b/src/main/java/com/google/gwtjsonrpc/server/SqlTimestampDeserializer.java @@ -22,9 +22,9 @@ import com.google.gson.JsonParseException; import com.google.gson.JsonPrimitive; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; +import com.google.gwtjsonrpc.client.impl.ser.JavaSqlTimestamp_JsonSerializer; import java.lang.reflect.Type; -import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.TimeZone; @@ -45,12 +45,8 @@ public class SqlTimestampDeserializer implements if (!p.isString()) { throw new JsonParseException("Expected string for timestamp type"); } - try { - final long when = newFormat().parse(p.getAsString()).getTime(); - return new java.sql.Timestamp(when); - } catch (ParseException e) { - throw new JsonParseException("Not a timestamp string"); - } + + return JavaSqlTimestamp_JsonSerializer.parseTimestamp(p.getAsString()); } public JsonElement serialize(final java.sql.Timestamp src, |