Java TimeZone To toLocalTZ(Date time, TimeZone localTimeZone)

Here you can find the source of toLocalTZ(Date time, TimeZone localTimeZone)

Description

to Local TZ

License

Apache License

Parameter

Parameter Description
time a parameter
localTimeZone a parameter

Declaration

public static Date toLocalTZ(Date time, TimeZone localTimeZone) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.*;

public class Main {
    /**//from  w ww. ja  v  a 2 s.  c om
     * 
     * @param time
     * @param localTimeZone
     * @return
     */
    public static Date toLocalTZ(Date time, TimeZone localTimeZone) {
        if (localTimeZone == null) {
            return time;
        }
        return new Date(time.getTime() + (localTimeZone.getRawOffset() - TimeZone.getDefault().getRawOffset()));
    }
}

Related

  1. extractTimeZone(String strdate, Date thedate)
  2. parseTimeZoneString(String timeZoneString)
  3. setTimeZone(String name)
  4. timeZoneToCode(TimeZone tz)
  5. timeZoneToString(TimeZone tz)