File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes TimeZone Conversion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "TimeZone Conversion" Watch "TimeZone Conversion" New topic
Author

TimeZone Conversion

Amit Ghilidyal
Greenhorn

Joined: Mar 14, 2000
Posts: 2
HI
i would appreciate if any one could help me.
I need to convert date generated from a any given timezone
to any other timezone.
thanx
amit


amit_doon
Tom P
Ranch Hand

Joined: May 06, 2000
Posts: 88
You can use the TimeZone and Calendar objects to do all the work for you. You just have to know the time zone id for the time zones you want to convert.
Let's assume that you want to convert from eastern standard time to pacific standard time:
TimeZone tzPST = TimeZone.getTimeZone("PST");
TimeZone tzEST = TimeZone.getTimeZone("EST");
Calendar calPST = new GregorianCalendar(tzPST);
Calendar calEST = new GregorianCalendar(tzEST);
// now load calEST with the time you want to convert
calPST.setTime(calEST.getTime());
//calPST now has the time in pacific standard time
System.out.println(calPST.get(Calendar.HOUR_OF_DAY) + ":" + calPST.get(Calendar.MINUTE));
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: TimeZone Conversion