Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
java.util.Date fromDate = cal.getTime();
System.out.println(fromDate);
The above code doesn’t print the date in GMT, but rather prints in the local timezone. How do I get a GMT equivalent date from the current date (assuming that the program can run in Japan or SFO)
How about this –
Test Result :
UTC Time – Tue May 15 16:24:14 IST 2012
GMT Time – Tue May 15 10:54:14 IST 2012