Convert GMT to EST

In this section, you will learn to convert GMT to EST. The GMT stands for Greenwich Mean Time and EST stands for Eastern Standard Time.

Convert GMT to EST

In this section, you will learn to convert GMT to EST. The GMT stands for Greenwich Mean Time and EST stands for Eastern Standard Time.

Convert GMT to EST

Convert GMT to EST

     

In this section, you will learn to convert GMT to EST. The GMT stands for Greenwich Mean Time and EST stands for Eastern Standard Time.

Description of program:

This example helps you in converting GMT to EST on the console. The SimpleDateFormat() constructor uses the given pattern and date format symbols. Here we use the date format as gmt and est. And we pass it to the  isetTimeZone()  method that invokes with SimpleDateFormat object and provides a date in the EST format. 

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

public class GMTtoEST{
  public static void main(String args[]){

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

Output of the program:

C:\unique>javac GMTtoEST.java

C:\unique>java GMTtoEST
GMT Time: 8/4/07 4:49 AM
EST Time: 8/3/07 11:49 PM

C:\unique>

Download this example.