Closed GoogleCodeExporter closed 9 years ago
Please try DateTime and let me know if it doesn't meet your needs:
http://javadoc.google-http-java-client.googlecode.com/hg/1.12.0-beta/com/google/
api/client/util/DateTime.html
Original comment by yan...@google.com
on 26 Nov 2012 at 3:37
I have tested that. Still doesn't work. Im using GsonFactory.
Here is code to reproduce:
try {
DateTime date = jsonFactory.fromString("2012-11-24T08:05:42.495Z", DateTime.class);
Log.d(TAG, "timestamp:" + date.getValue());
} catch (Exception e) {
Log.w(TAG, e);
}
Get IllegalArgumentException:
ava.lang.IllegalArgumentException:
at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:644)
at com.google.api.client.json.JsonParser.parse(JsonParser.java:289)
at com.google.api.client.json.JsonParser.parse(JsonParser.java:266)
at com.google.api.client.json.JsonFactory.fromString(JsonFactory.java:207)
Original comment by alexey.v...@gmail.com
on 28 Nov 2012 at 8:50
that's because you're missing the quotes, ie this should work correctly:
DateTime date = jsonFactory.fromString("\"2012-11-24T08:05:42.495Z\"", DateTime.class);
That said, we can probably improve the error message.
Original comment by yan...@google.com
on 28 Nov 2012 at 3:30
Original issue reported on code.google.com by
alexey.v...@gmail.com
on 26 Nov 2012 at 3:44