Conversion of local TimeZone to GMT in Java

import java.util.*;
import java.text.*;
 
public class Test {
      public static void main(String args[]) {
            Date date = new Date();
            DateFormat gmtFormat = 
                   new SimpleDateFormat("dd-MM-yyyy hh:MM:ss");
            TimeZone gmtTime = TimeZone.getTimeZone("GMT");
            gmtFormat.setTimeZone(gmtTime);
            System.out.println("Current Time: " + date);
            System.out.println("GMT Time: " + gmtFormat.format(date));
      }
}
 


Enter your email address to get our daily JOBS & INTERVIEW FAQ's Straight to your Inbox.

Make sure to activate your subscription by clicking on the activation link sent to your email