Java ZoneId getTimeZoneId(final TimeZone tz)

Here you can find the source of getTimeZoneId(final TimeZone tz)

Description

Get time zone id .ZoneId.SHORT_IDS used get id if time zone is abbreviated like 'IST'.

License

Open Source License

Parameter

Parameter Description
tz a parameter

Return

ZoneId

Declaration

public static ZoneId getTimeZoneId(final TimeZone tz) 

Method Source Code

//package com.java2s;
/**//from www  .ja  v  a  2s  . c  o  m
 * Copyright (c) 2015 Bosch Software Innovations GmbH and others.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */

import java.time.ZoneId;

import java.util.TimeZone;

public class Main {
    /**
     * Get time zone id .ZoneId.SHORT_IDS used get id if time zone is
     * abbreviated like 'IST'.
     *
     * @param tz
     * @return ZoneId
     */
    public static ZoneId getTimeZoneId(final TimeZone tz) {
        return ZoneId.of(tz.getID(), ZoneId.SHORT_IDS);
    }
}

Related

  1. getDefaultTimeZone()
  2. getDefaultZoneId()
  3. getDefaultZoneId()
  4. getRequestTimeZone(String timestamp)
  5. getTimezone(String tzid)
  6. getZoneDateTime(Date d, String tzId)
  7. getZoneId()
  8. getZoneId(String tzId)
  9. now()