Ok, so I’ve pretty much tried everything. I bet it’s something really simple but I can’t seem to get a hold of it.
The server sends me the time, which is epoch. However when I put this into a date object it seems to automatically pick up the time zone and it adds +3 to the server time. So if the gmt time is 00.00, it says its 03.00.
I also need to add a timezone of my own. Let’s say the epoch time is 00.00 again, it should read 10.00 after I add the timezone.
any help would be much appreciated. Thank you
“It seems to add” – I suspect you’re using
Date.toString()which does indeed use the local time zone. TheDateobject itself is effectively in UTC though. UseDateFormatto perform the conversion to a string instead, and you can specify which time zone to use. You may also need to useCalendar– it depends what you’re trying to do.(Alternatively, use Joda Time in the first place, which is a better API. It may be a little bulky for your Android project though. I wouldn’t be surprised if there were a “Joda Time lite” project around somewhere for precisely this sort of thing…)
EDIT: Quick sample, although it’s not entirely clear what you need…