I'm new to time zones in Java
I get from the server, the following String:
`"startDateTime": "2014-08-10T20:08:09.8948Z"`
I'm not sure what does the Z mean? How can I know from my android app
in what time zone did the server saved the date?
Today I use this code:
public class DateFormatter implements JsonDeserializer {
@Override
public Date deserialize(JsonElement element, Type arg1,
JsonDeserializationContext arg2) throws JsonParseException {
String date = element.getAsString();
SimpleDateFormat formatter = new SimpleDateFormat(
"yyyy-MM-dd'T'HH:mm:ss.SSS", Locale.getDefault());
// formatter.setTimeZone(TimeZone.getDefault());
try {
return formatter.parse(date);
} catch (ParseException exp) {
// System.err.println("Failed to parse Date:", exp);
return null;
}
}
public String toStringFormat(Date date) throws JsonParseException {
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm dd/mm/yy",
Locale.getDefault());
// formatter.setTimeZone(TimeZone.getDefault());
return formatter.format(date);
}
}
but what does Locale.getDefault
returns? How does it know in which time zone am I ?
Is there any reliable and easy to use open source jar to ease the time zones shifting?