3

For 2016 Turkish Government decided to stay GMT+3 timezone to save daylight, but on android:

Calendar calendar = Calendar.getInstance();
TimeZone tz = TimeZone.getTimeZone("UTC");
calendar.setTimeInMillis(timestamp * 1000);
Date currentTimeZone = (Date) calendar.getTime();
calendar.add(Calendar.MILLISECOND, tz.getOffset(calendar.getTimeInMillis()));

So the problem is;
it's showing GMT+3 for the date before November:
Wed Oct 26 18:00:00 GMT+03:00 2016
but for after November:
Mon Nov 07 20:00:00 GMT+02:00 2016

it should've stay at GMT+3 for the whole year, is that a special issue to android lib of TimeZone or am I doing something wrong?
Thanks,

UPDATE
Although I've added a check for timezone and gmt parameters,
The situation will be a little chaotic for the Android devices that uses Turkey's timezone, cause after Oct 29 the hour of device will be an hour early than normal, until Android releases a update for that and user applies that.

Canberk Ozcelik
  • 631
  • 1
  • 11
  • 26

1 Answers1

5

See the release note of tzdb-database for version 2016g:

Release 2016g - 2016-09-13 08:56:38 -0700

Changes to future time stamps

Turkey switched from EET/EEST (+02/+03) to permanent +03,
effective 2016-09-07.  (Thanks to Burak AYDIN.)  
Use "+03" rather than an invented abbreviation for the new time.

Obviously, your Android device still uses an outdated timezone version. Actually you have following options to proceed:

  • Wait for a new Android version (not attractive, not recommended).
  • Use another external library like Joda-Time-Android or my library Time4A which already use 2016h (Threeten-ABP is still behind, actually on 2016e).
  • Or write your own hack using fixed offsets for Turkey, for example TimeZone.getTimeZone("GMT+03")
Meno Hochschild
  • 42,708
  • 7
  • 104
  • 126
  • Shouldn't that last one be `Etc/GMT-3` - or does Android have additional aliases? – Matt Johnson-Pint Oct 26 '16 at 16:23
  • @MattJohnson According to the [Android documentation](https://developer.android.com/reference/java/util/TimeZone.html), writing "GMT+03" should be possible, and I would prefer it compared with the confusing notation based on Etc/GMT (due to opposite sign). – Meno Hochschild Oct 26 '16 at 17:08
  • Using one of these solutions will not work for android users in turkey, since they will not update anything. In my app I've decided to check for timezone and time checks which, is the user in Europe/Istanbul timezone and has GMT+2, but another problem occurs with this solution is not all android versions and devices has Europe/Istanbul timezone ID :( – Canberk Ozcelik Oct 31 '16 at 08:55
  • @CanberkÖzçelik If a user does not want to update anything then he/she must live with wrong local time. However, I don't believe that most users will accept a wrong time, so they stick any lazyness and will do something: a) update Android OS, b) update your app or c) override their system clock (not a recommended user hack). The only thing YOU can do is offering a new version of your app. – Meno Hochschild Oct 31 '16 at 11:46