JAVA – Convert GMT to EST


The following code snippet convert GMT to EST in java.

import java.util.*;
import java.io.*;
import java.text.*;


public class GmtToEstConversion 

{

  public static void main(String args[]) throws Exception
  
  {

  Date date = new Date();
  DateFormat est = new SimpleDateFormat();
   TimeZone estTime = TimeZone.getTimeZone("EST");
  DateFormat gmt = new SimpleDateFormat();
  TimeZone gmtTime = TimeZone.getTimeZone("GMT");
  est.setTimeZone(gmtTime);
  gmt.setTimeZone(estTime);
  System.out.println("GMT Time: " + est.format(date));
  System.out.println("EST Time: " + gmt.format(date));
  }
  
}

 


After execution of above program we will get the output like below:-


 

Leave a Reply

Your email address will not be published. Required fields are marked *