Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

System Time - TimeZones

843798Oct 9 2006 — edited Oct 11 2006
Hi

I have some problem with sys time in JRE:

On server in Romania (Win 2000 Eng, TimeZone Bucharest GMT+2)
The local time that I see near tray is properly !

But All Java applications have logs with time put forward by one hour ! Lets say that now is 12 o'clock but in application we see 13 o'clock.

I wrote some simple application that displays local time and set TimeZone for sure, it compares Romanian time with Polish:

GregorianCalendar gCalendar = new GregorianCalendar(TimeZone.getTimeZone("Europe/Bucharest"));


SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss");
System.out.println("In Romania:(Europe/Bucharest) ");
sdf.setTimeZone(TimeZone.getTimeZone("Europe/Bucharest"));
System.out.println(sdf.format(gCalendar.getTime()));

String [] timezones = TimeZone.getAvailableIDs();
for (int i =0 ; i < timezones.length ; i++)
System.out.println(timezones);

System.out.println("\nIn Poland:(Europe/Sarajevo) ");
sdf.setTimeZone(TimeZone.getTimeZone("Europe/Sarajevo"));
System.out.println(sdf.format(gCalendar.getTime()));

System.out.println("\nLocal Time zone: ");
System.out.println("TimeZone: "+TimeZone.getDefault().getID());
System.out.println(new SimpleDateFormat("MM-dd-yyyy HH:mm:ss").format(Calendar.getInstance().getTime()));

TimeZone.setDefault(TimeZone.getTimeZone("Europe/Bucharest"));

System.out.println("\n");
System.out.println("Date using system.CurentTimemillis after setting default timezone");

Date d = new Date(System.currentTimeMillis());
System.out.println(new SimpleDateFormat("MM-dd-yyyy HH:mm:ss").format(d));


/////////////////////////////////////////////////////

After call this main on local computer (Poland) i get good Time:

In Romania:(Europe/Bucharest)
10-06-2006 12:01:54


In Poland:(Europe/Sarajevo)
10-06-2006 11:01:54

Local Time zone:
TimeZone: Europe/Belgrade
10-06-2006 11:01:54

Date using system.CurentTimemillis after setting default timezone
10-06-2006 12:01:54


/////////////////////////////////////////////


After I call this main on Romanian server i get time that is put forward by one hour !:


In Romania:(Europe/Bucharest)
10-06-2006 13:00:25

In Poland:(Europe/Sarajevo)
10-06-2006 12:00:25

Local Time zone:
TimeZone: Europe/Bucharest
10-06-2006 13:00:25

Date using system.CurentTimemillis after setting default timezone
10-06-2006 13:00:25


I repeat, time zone and time on Romanian server is set properly.

It looks like JRE see all Time zones are put forward by 1 hour :/

Please help.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 8 2006
Added on Oct 9 2006
3 comments
226 views