Java Date and Time

I am using the following code to create data and time values for a program and the Date class i am using is java.util.Date.

Date d = new Date();

System.out.println(d.toString());

When it prints the date the time is one hour behind my operating system(which has the correct time), Windows XP, the same occurs when a new class is created and has time, date and name information in the comments at the top of the class.

However when i run the program on another computer it works.

Can anyone help me with this and explain a way to make sure that the Operating systems time is always used.

Thank you very much.

[656 byte] By [Patrick-McDonogh] at [2007-9-30 14:27:11]
# 1
It sounds like you have a problem with timezones.Are you in the same timezone as the UK? i.e. GMT+1 This would explain the one hour time difference.
Peter-Lawrey at 2007-7-5 2:03:31 > top of Java-index,Administration Tools,Sun Connection...
# 2
Yes i am in the U.K. but still even so i dont know how to always get the systems (Machine program running on) time. But i think you are on the right track ill experiment a bit more with it..Thankyou very much
Patrick-McDonogh at 2007-7-5 2:03:31 > top of Java-index,Administration Tools,Sun Connection...
# 3
You can make use of java.util.Calendar to replace the Date orsimply use System.currentTimeMillis();
mscsam at 2007-7-5 2:03:31 > top of Java-index,Administration Tools,Sun Connection...
# 4
Sounds like your Windows is set to a time zone that isn't respecting Daylight Savings - or handles it differently than does Java.
ChuckBing at 2007-7-5 2:03:31 > top of Java-index,Administration Tools,Sun Connection...
# 5

Ah yes, thankyou to all of your replies, i have tried all three and they all work, my favourite is using the callendar instead of the date class and also the setting on the operating systems wasnt making use of daylight saving which was why it was one hour behind.

Thankyou very much for the help

Patrick-McDonogh at 2007-7-5 2:03:31 > top of Java-index,Administration Tools,Sun Connection...