I get a date from the service in milliseconds and UTC.
I need to transform into the User's Time Zone.
For this I did the following:
public static void main(String[] args) {
// Milisegundos está em UTC...
long time = 1457037493000L;
String format = "HH:mm:ss";
SimpleDateFormat sdfUtc = new SimpleDateFormat(format, Locale.getDefault());
sdfUtc.setTimeZone(TimeZone.getTimeZone("UTC"));
SimpleDateFormat sdfLocal = new SimpleDateFormat(format, Locale.getDefault());
sdfLocal.setTimeZone(TimeZone.getDefault()); // Meu TimeZone é -3...
System.out.println("Local : "+sdfLocal.format(time));
System.out.println("UTC : "+sdfUtc.format(time));
}
Result:
Location: 17:38:13
UTC: 20:38:13
Actually 17:38:13
is the time in UTC!
And the location would be 14:38:13
because my Time Zone is -3.
How do I fix the date in UTC for the user's Time Zone?