1

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 ?

0

2 Answers 2

6

It sounds like the two computers have their clocks set to different time zones.

Sign up to request clarification or add additional context in comments.

1 Comment

where can i fix the time zone?
2

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); 

2 Comments

hi , i removed the accept , beaocse in my pc it fixed the problem but in others the time is still wrong and its dosn't do any thing its just dosn't work , what else can it be ?
The result of s in this code must return the exact same on every machine

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.