2 Replies Latest reply: Nov 15, 2007 1:46 PM by 807603 RSS

    Help converting Calendar timezones!

    807603
      I am getting Date strings from a Web Service in the following format:

      2007-11-14 22:30:49.710

      They are in GMT time.

      I create Calendar objects and parse that date String like so:

      SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
      Calendar date = new GregorianCalendar(TimeZone.getTimeZone("GMT"));     
      date.setTimeInMillis(sdf.parse(dateString).getTime());          

      I output the date now.

      I then convert it to EST (local timezone):
      date.setTimeZone(TimeZone.getDefault());

      Then I output the date, and it is the same exactly time I started with- what gives?

      How I output:
      System.out.println(date.getTimeZone().getDisplayName()+" = "+sdf.format(date.getTime()));

      Example output:

      Greenwich Mean Time = 2007-11-14 22:30:49.710
      Eastern Standard Time = 2007-11-14 22:30:49.710

      No change! Help!