The Artima Developer Community
Sponsored Link

Java Answers Forum
Need help with dates

1 reply on 1 page. Most recent reply: Jan 25, 2003 7:17 PM by Charles Bell

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Swaraj

Posts: 24
Nickname: swaraj
Registered: Mar, 2002

Need help with dates Posted: Jan 25, 2003 2:20 AM
Reply to this message Reply
Advertisement
Hi

Is it possible to convert a date in GMT to IST using Date Object functions in Java ?

Swaraj


Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: Need help with dates Posted: Jan 25, 2003 7:17 PM
Reply to this message Reply
I do not know what IST stands for?

In the U.S. there is EST, CST, MST, and PST or under daylight savings time, EDT, CDT, MDT, and PDT.

GMT is Greenwich Mean Time or UT.

EST = GMT - 5 hours.
CST = GMT - 6 hours.
MST = GMT - 7 hours.
PST = GMT - 8 hours.

EDT = GMT - 6 hours + 1 hour.
CDT = GMT - 6 hours + 1 hour.
MDT = GMT - 7 hours + 1 hour.
PDT = GMT - 8 hours + 1 hour.

Since an hour is 3600 seconds or 3600 x 1000 milliseconds, it should be easy to convert any date to a different time zone.

Date date1 = new Date();
long millisecs= date1.getTime().
long oneHourMillisecs = 3600 * 1000;
long hoursOffset = 5;
Date date2 = new Date(millisecs + hoursOffset * oneHourMillisecs);

Flat View: This topic has 1 reply on 1 page
Topic: Print the Reporting Previous Topic   Next Topic Topic: urgenthelp

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use