Results 1 to 3 of 3
  1. #1
    denyr is offline Member
    Join Date
    Jun 2011
    Posts
    2
    Rep Power
    0

    Default Timezone issues with SG timezone on Windows 2003

    Hi, I created a simple java application to test out the timezone settings on a Windows 2003 server.
    The server has been set to take the "(GMT +08:00) Kuala Lumpur, Singapore" timezone via the Date/Time control panel. Below is the application code and result:
    -----
    (Code)
    import java.text.*;
    import java.util.Date;
    import java.util.Locale;
    import java.util.TimeZone;


    public class TestDate {

    /**
    * @param args
    */
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    Date dt = new Date();
    SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
    System.out.println("With a java.util.Date object of "+dt+" todays date is "+df.format(dt));

    System.out.println(Locale.getDefault().toString()) ;
    System.out.println("Timezone: "+ TimeZone.getDefault().getID());
    System.out.println("UTCOffset: " + (TimeZone.getDefault().getRawOffset()/(60*60*1000)) + " , DST:" + (TimeZone.getDefault().getDSTSavings()/(60*60*1000)));


    }

    }

    -----
    (Result)
    With a java.util.Date object of Fri Jun 24 03:59:25 GMT 2011 todays date is 20110624
    en_GB
    Timezone: GMT
    UTCOffset: 0 , DST:0
    -------

    When set to HongKong(China Standard Time), I get the results as expected:
    -------
    With a java.util.Date object of Fri Jun 24 12:00:26 CST 2011 todays date is 2011
    0624
    en_GB
    Timezone: Asia/Shanghai
    UTCOffset: 8 , DST:0
    -------

    Has anyone come across the above before and how can I resolve this other than explicitly setting the JVM user.timezone parameters?

    Thanks.

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default

    When I changed the time zone to Kuala Lumpur & Singapore I got Asia/Singapore as output. It would seem one or more of your assumptions are incorrect.

  3. #3
    denyr is offline Member
    Join Date
    Jun 2011
    Posts
    2
    Rep Power
    0

    Default

    Hi Junky, when I tried on my Windows XP machine, it works fine - so, it is just not working for the Windows 2003 server machine.

Similar Threads

  1. TimeZone confusion
    By justc1 in forum Advanced Java
    Replies: 1
    Last Post: 06-22-2011, 08:31 AM
  2. Timezone in java
    By deeparanbhor in forum New To Java
    Replies: 0
    Last Post: 05-28-2009, 02:12 PM
  3. Regarding olson timezone database
    By navneet.tech2009@gmail.co in forum New To Java
    Replies: 0
    Last Post: 09-23-2008, 01:47 PM
  4. How to use TimeZone class of java
    By Java Tip in forum java.util
    Replies: 0
    Last Post: 04-06-2008, 08:39 PM
  5. How to accurately test if timezone data is updated?
    By Santhosh in forum Advanced Java
    Replies: 0
    Last Post: 11-14-2007, 07:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •