Calendar.getInstance(TimeZone.getTimeZone("GMT+1")).get(Calendar.HOUR_OF_DAY)
is an hour "slow", (possibly because they does not detect the daylight saving +1 hour.) In J2SE, there are a lot of available time zones (Europe/Budapest too, and it works perfectly), but in J2ME there are only GTM and UTC.
How can I get the "right" hour?
views:
453answers:
3You've asked for "GMT+1" which is a fixed time zone - no daylight saving is applied. If you need to apply daylight saving and J2ME doesn't supply any DST time zones, you're going to have to work out that logic yourself :(
(In other words, it sounds like J2ME is behaving correctly, but it doesn't support the feature you want it to.)
I just had this issue with a completely different application - it was a mobile application, but it turned out to be a paradigm issue with my way of thinking, not a programmatic problemn at all... I wonder if this is the same issue you're having.
Currently England is on British Summer Time, so what people often consider GMT is the time it currently is in England... which is not always GMT. BST is GMT+1, which (depending on your location and whether or not you use daylight savings) could cause issues. This would also affect the date if GMT is a day behind.
For instance, I'm presently in Toronto, which is currently GMT-4, but is 5 hours behind London which caused me a great deal of confusion. I think what added to the confusion is that I'm from the UK so I automatically think of the time as GMT-5 which is not always the case. London time is currently GMT+1 and we're London-5 which is actually GMT-4.
I've tried with TimeZone.getDefault()
on my phone and it worked :) (but on the emulator the hour was "slow" by 2 hours :S )