Reputation: 30885
i have weird situation i have simple code that looks like this :
Date d = new Date(1308670980000L);
SimpleDateFormat f = new SimpleDateFormat("dd.MM.yyyy,HH:mm");
String s = f.format(d);
some computers im getting : 21.06.2011 15:43 and this is the date that
im expecting to get and its fine .
but on other pc's im getting :21.06.2011,18:43 i dont know why im getting this date.
what can be wrong in the pc or java configuration that gives me this ?
Upvotes: 1
Views: 1586
Reputation: 105220
It depends on the default timezone.
If you want the GMT time you need to do something like this:
Date d = new Date(1308670980000L);
SimpleDateFormat f = new SimpleDateFormat("dd.MM.yyyy,HH:mm");
f.setTimeZone(TimeZone.getTimeZone("GMT");
String s = f.format(d);
Upvotes: 2
Reputation: 359776
It sounds like the two computers have their clocks set to different time zones.
Upvotes: 6