Home Java Java-conversion Convert GMT to EST
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Convert GMT to EST

Advertisement
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.

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.

Advertisement

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: December 18, 2008

Ask Questions?    Discuss: Convert GMT to EST   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com