Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Java Java-conversion Convert GMT to CET

Related Tutorials


 
 

Share on Google+Share on Google+

Convert GMT to CET

Advertisement
In this section, you will learn to convert a GMT to CET format. The GMT stands for Greenwich Mean Time and CET stands for Central European Time.

Convert GMT to CET

     

In this section, you will learn to convert a GMT to CET format. The GMT stands for Greenwich Mean Time and CET stands for Central European  Time.

Description of program:

This example helps you in converting a GMT time to CET time on the console. The SimpleDateFormat() constructor uses the given pattern and date format symbols. Here we use the date format as gmtFormat which gets converted to cetFormat. Then we have used  getTimeZone() method to get the time of both the zones to be converted. 

Central European Time (CET)

Standard Time = GMT+1
Summer Time = GMT+2 

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

public class GMTtoCET{
  public static void main(String args[]){
  Date date = new Date();
  DateFormat cetFormat = new SimpleDateFormat();
  DateFormat gmtFormat = new SimpleDateFormat();
  TimeZone gmtTime = TimeZone.getTimeZone("GMT");
  TimeZone cetTime = TimeZone.getTimeZone("CET");
  cetFormat.setTimeZone(gmtTime);
  gmtFormat.setTimeZone(cetTime);
  System.out.println("GMT Time: " + cetFormat.format(date));
  System.out.println("CET Time: " + gmtFormat.format(date));
  }
}

Output of the program:

C:\unique>javac GMTtoCET.java

C:\unique>java GMTtoCET
GMT Time: 8/4/07 9:32 AM
CET Time: 8/4/07 11:32 AM

C:\unique>

Download this program.

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



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 12, 2008

Related Tutorials

Discuss: Convert GMT to CET  

Post your Comment


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