[an error occurred while processing this directive]

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");
      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


Download this program.


[an error occurred while processing this directive]