Java TimeZone class

Introduction

The abstract TimeZone class works with time zone offsets from Greenwich mean time (GMT).

GMT is also referred to as Coordinated Universal Time (UTC).

The following code creates TimeZone object and changes the TimeZone id.

import java.util.TimeZone;

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

        TimeZone tzone = TimeZone.getDefault();

        // set time zone ID
        tzone.setID("GMT+08:00");

        // checking time zone ID
        System.out.println("Time zone ID:" + tzone.getID());
    }//from ww  w  .ja  va 2 s .  c  o m
}



PreviousNext

Related