1 Reply Latest reply on Oct 19, 2007 12:50 AM by Elias Ross

    Urgent : Time getting different than system time

    SOnali Salunkhe Newbie

      In one of the method of one class which is deployed on JBOSS, I have written the following lines of code :


      SimpleDateFormat dateFormatterSecondPrecision = new SimpleDateFormat("MM/dd/yyyy kk:mm:ss");
      System.setProperty("user.timezone","America/Los_Angeles");
      Calendar cal = GregorianCalendar.getInstance(TimeZone.getTimeZone("America/Los_Angeles"));

      String strCreatedDate=dateFormatterSecondPrecision.format(cal.getTime());

      if(INFO) // used log4j
      log.info("..... strCreatedDate : "+strCreatedDate);

      java.util.Date createdDate=dateFormatterSecondPrecision.parse(strCreatedDate);

      if(INFO)
      log.info("..... createdDate : "+createdDate);

      The o/p :

      ..... strCreatedDate : 10/18/2007 13:32:33

      ..... createdDate : Thu Oct 18 13:32:33 GMT 2007



      But if I run the code soley, toatlly written a simple java class which contain the above 4-5 liines,

      The o/p is :

      ..... strCreatedDate : 10/18/2007 19:05:45

      ..... createdDate : Thu Oct 18 19:05:45 IST 2007



      The difference of 5.5 hrs is coming .

      Can anybody tell me where i m wrong?

      Thanks in advance