Java.util.GregorianCalendar.setTimeZone() 方法


Java.util.GregorianCalendar.setTimeZone() 方法

package com.codingdict;

import java.util.*;

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

      // create a new calendar
      GregorianCalendar cal = (GregorianCalendar) GregorianCalendar.getInstance();

      // print the current date and time
      System.out.println("" + cal.getTime());

      // set to another time zone
      cal.setTimeZone(TimeZone.getTimeZone("GMT"));
      System.out.println("New Time Zone:" + cal.getTimeZone().getDisplayName());
   }
}