Java – GMT to IST Conversion


The following code snippet convert GMT to IST in java.

 

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


public class GmtToIstConversion 

{

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

  Date date = new Date();
  DateFormat est = new SimpleDateFormat();
   TimeZone estTime = TimeZone.getTimeZone("IST");
  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("IST Time: " + gmt.format(date));
  }
  
}

 


After execution of above code you get the Output like below:-


 

Leave a Reply

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