Results 1 to 2 of 2
  1. #1
    JRuyechan is offline Member
    Join Date
    Oct 2010
    Rep Power

    Default converting string (GMT date) to date in US time.

    I'm trying to convert a string (date in GMT time) to a date and then convert that date from GMT time to US time. Us time depends on facilites local timezone. The date string is parsed from XML message. I retrieve the GMToffset.

    String gmtFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
    gmtOffSet = "GMT-04:00";
    String datein = "2010-10-12T20:01:18.000Z";

    SimpleDateFormat sdf = new SimpleDateFormat(gmtformat);
    dateStringin = sdf.parse(datein); //but this parses the date to EDT time (default of system)

    //convert from GMT to timezone needed
    TimeZone tz = TimeZone.getTimeZone(GMTOffSet);
    dateStr = sdf.format(dateStringin);

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Rep Power


    Set the timezone on "gmtFormat" before parsing the date String.

Similar Threads

  1. convert String date to Date
    By computerbum in forum New To Java
    Replies: 7
    Last Post: 09-18-2010, 03:26 PM
  2. How to display date & time on GUI?
    By BluXit in forum New To Java
    Replies: 5
    Last Post: 05-26-2010, 11:33 AM
  3. Time and Date
    By Manfizy in forum New To Java
    Replies: 0
    Last Post: 05-27-2009, 12:58 PM
  4. Date/Time Servlet
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-14-2008, 10:34 AM
  5. Converting Epoch to string Date
    By amyedwards in forum New To Java
    Replies: 3
    Last Post: 12-14-2007, 11:33 PM

Posting Permissions

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