Many questions about timezones in Android were already asked here on SO, however after going through all of them I still don't have the definitive answer why the following is happening:
Let's say I live in Germany, therefore have the preferred timezone offset +1. Then I decided to go to the US. While in the US, my device sends a message to the server with the timestamp local to where I am now in the US. I use the following code to get the timestamp:
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSSSSZ");
fmt.setTimeZone(TimeZone.getDefault());
String timeStamp = fmt.format(new Date());
the timestamp I get is for example: 2016-02-20 08:32:01.000769+01
while 08:32:01
is the right time at the place where I am at that moment, the offset is still +1
, whereas it should be rather something like -6
.
From the answers here on SO, I got the impression that the Android devices don't care about the current timezone (given by my current location) and still insist on the original preferred timezone.
So am I right the only way to get this correct is to query some server with my coordinates to get my current timezone?
How come the device automatically syncs with the current network time as I travel, but does not sync the timezone offset? The cell towers should know in which timezone offset they are operating.