Java TimeZone Create getTimezoneAbbreviation(String tzid, boolean dst)

Here you can find the source of getTimezoneAbbreviation(String tzid, boolean dst)

Description

get Timezone Abbreviation

License

Open Source License

Declaration

private static String getTimezoneAbbreviation(String tzid, boolean dst) 

Method Source Code

//package com.java2s;
/*//  www .  j  a  v a 2s  .  c  o  m
 * ***** BEGIN LICENSE BLOCK *****
 * Zimbra Collaboration Suite Server
 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Synacor, Inc.
 *
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software Foundation,
 * version 2 of the License.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License along with this program.
 * If not, see <https://www.gnu.org/licenses/>.
 * ***** END LICENSE BLOCK *****
 */

import java.text.DateFormatSymbols;

public class Main {
    private static final String[][] ZONE_INFO = new DateFormatSymbols().getZoneStrings();

    private static String getTimezoneAbbreviation(String tzid, boolean dst) {
        if (tzid == null)
            return null;

        for (int tzindex = 0; tzindex < ZONE_INFO.length; tzindex++) {
            if (tzid.equalsIgnoreCase(ZONE_INFO[tzindex][0]))
                return dst ? ZONE_INFO[tzindex][4] : ZONE_INFO[tzindex][2];
        }
        return null;
    }
}

Related

  1. getTimeZone(String id)
  2. getTimeZone(String idParam)
  3. getTimeZone(String timeZone)
  4. getTimeZone(String timeZone)
  5. getTimeZone(String timeZoneId)
  6. getTimeZoneChecked(String id)
  7. getTimeZoneCorrectedProgramId(String progID)
  8. getTimeZoneDefault()
  9. getTimeZoneIds()