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.

Ads

Tutorials   
Ads

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.

Advertisements

Share on Google+Share on Google+

Convert GMT to EST

Posted on: December 18, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

Ads
 

Discuss: Convert GMT to EST   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0

Ads

 

Ads