Am trying convert date which is in local time zone to GMT, i did some thing like this
SimpleDateFormat sdf = new SimpleDateFormat(\"MM/dd/yyyy HH:mm:ss\");
import java.util.*;
import java.text.*;
public class CurrentTimeToGMT{
public static void main(String args[]){
Date date = new Date();
DateFormat gmtFormat = new SimpleDateFormat();
TimeZone gmtTime = TimeZone.getTimeZone("GMT");
gmtFormat.setTimeZone(gmtTime);
System.out.println("Current Time: "+date);
System.out.println("GMT Time: " + gmtFormat.format(date));
}
}
Output
Current Time: Wed Mar 10 11:21:18 IST 2010 GMT Time: 3/10/10 5:51 AM