Results 1 to 2 of 2
- 10-14-2010, 10:05 PM #1
Member
- Join Date
- Oct 2010
- Posts
- 1
- Rep Power
- 0
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);
sdf.setTimeZone(tz);
dateStr = sdf.format(dateStringin);
- 10-15-2010, 08:07 AM #2
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,568
- Rep Power
- 15
Similar Threads
-
convert String date to Date
By computerbum in forum New To JavaReplies: 7Last Post: 09-18-2010, 04:26 PM -
How to display date & time on GUI?
By BluXit in forum New To JavaReplies: 5Last Post: 05-26-2010, 12:33 PM -
Time and Date
By Manfizy in forum New To JavaReplies: 0Last Post: 05-27-2009, 01:58 PM -
Date/Time Servlet
By Java Tip in forum Java TipReplies: 0Last Post: 01-14-2008, 10:34 AM -
Converting Epoch to string Date
By amyedwards in forum New To JavaReplies: 3Last Post: 12-14-2007, 11:33 PM
Bookmarks