Example
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
public class GMTExample {
public static void main(String[] args) throws ParseException {
SimpleDateFormat gmtDateFormat = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss.SSS Z");
gmtDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
String currentGMTDateString = gmtDateFormat.format(new Date());
SimpleDateFormat gmtDateFormat1 = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss.SSS Z");
String currentDateString = gmtDateFormat1.format(new Date());
System.out.println("Current GMT=" + currentGMTDateString
+ " Current Local" + currentDateString);
}
}
Output
Current GMT=04-06-2014 07:18:25.939 +0000 Current Local04-06-2014 12:48:25.940 +0530
0 comments:
Post a Comment