View Single Post
  #2 (permalink)  
Old 05-08-2008, 09:32 PM
hardwired hardwired is offline
Senior Member
 
Join Date: Jul 2007
Posts: 1,017
hardwired is on a distinguished road
Code:
import java.text.*; import java.util.*; public class Test { public static void main(String[] args) { DateFormat df = new SimpleDateFormat("HHmm dd MMM yyyy"); TimeZone TIME_ZONE = TimeZone.getTimeZone("GMT-0"); System.out.println("TIME_ZONE = " + TIME_ZONE.getID()); Calendar calendar = Calendar.getInstance(); System.out.println("local TZ = " + calendar.getTimeZone().getID()); calendar.set(2008, 04, 10, 24, 00); // midnight gmt Date expDate = calendar.getTime(); System.out.printf("expDate = %s%n", df.format(expDate)); Calendar gmtCalendar = Calendar.getInstance(); calendar.setTimeZone(TIME_ZONE); gmtCalendar.setTime(expDate); Date gmtExpDate = gmtCalendar.getTime(); System.out.printf("gmtExpDate = %s%n", df.format(gmtExpDate)); Calendar calendarExp = new GregorianCalendar(TIME_ZONE); calendarExp.setTime(expDate); System.out.printf("calExpDate = %s%n", df.format(calendarExp.getTime())); } }
Reply With Quote