posted 24 years ago
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));