Serving the Quantitative Finance Community

 
User avatar
drona
Topic Author
Posts: 0
Joined: February 10th, 2002, 1:34 pm

Convert Date time to GMT

March 9th, 2004, 8:35 pm

.NET does not implement this, although java did have some excellent date utilfunctions. I am looking for a function that given date/time and timezone willconvert it to GMT. Probably a third party solution exists somewhere, any pointersappreciated.
 
User avatar
zooey
Posts: 0
Joined: January 11th, 2004, 4:55 pm

Convert Date time to GMT

March 9th, 2004, 9:06 pm

Will this help: Date d = (Calendar.getInstance()).getTime(); // Gives the current datetime for the default timezone.SimpleDateFormat ds = new SimpleDateFormat("MMM dd yyyy hh:mm:ss:SSSaa"); // Create a datetime format ds.setTimeZone(TimeZone.getTimeZone("GMT")); // Sets the timezone of the datetime format object to GMTString time = ds.format(d); ds.setTimeZone(TimeZone.getDefault()); // Set the timezone back to its original default value.If you observe, date object is the same but the way you show or read differs depending on the TimeZone you set to your datetime format object.Hope this helps.--Zooey
 
User avatar
drona
Topic Author
Posts: 0
Joined: February 10th, 2002, 1:34 pm

Convert Date time to GMT

March 10th, 2004, 12:28 am

Thanks, No it is not the correct way to do it.
 
User avatar
mic4
Posts: 0
Joined: March 6th, 2004, 10:09 am

Convert Date time to GMT

March 10th, 2004, 12:39 am

Better TZ support seems to be on most people's wishlist. Have you checked the J# java.util implementation (vjslib.dll)?
 
User avatar
zooey
Posts: 0
Joined: January 11th, 2004, 4:55 pm

Convert Date time to GMT

March 10th, 2004, 6:06 am

DronaMay I ask why you think it is not the correct way to do it?ThanksZooey