Java TimeZone To setTimeZone(String name)

Here you can find the source of setTimeZone(String name)

Description

Temporarily sets the default system timezone to the specified timezone ID.

License

Apache License

Parameter

Parameter Description
name a parameter

Declaration

public static void setTimeZone(String name) 

Method Source Code

//package com.java2s;
// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *

import java.util.*;

public class Main {
    private static ThreadLocal<TimeZone> systemTimeZone = new ThreadLocal<TimeZone>();

    /**//from ww  w .  j  av a 2 s  . c o m
     * Temporarily sets the default system timezone to the specified timezone ID.
     * Use {@link #unsetTimeZone()} to unset it.
     *
     * @param name
     */
    public static void setTimeZone(String name) {
        systemTimeZone.set(TimeZone.getDefault());
        TimeZone.setDefault(TimeZone.getTimeZone(name));
    }
}

Related

  1. createTimeZoneFromDouble(double timeZoneOffsetInHours)
  2. extractTimeZone(String strdate, Date thedate)
  3. parseTimeZoneString(String timeZoneString)
  4. timeZoneToCode(TimeZone tz)
  5. timeZoneToString(TimeZone tz)
  6. toLocalTZ(Date time, TimeZone localTimeZone)