1 /*
   2  * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package java.util.spi;
  27 
  28 import java.util.Locale;
  29 
  30 /**
  31  * An abstract class for service providers that
  32  * provide localized time zone names for the
  33  * {@link java.util.TimeZone TimeZone} class.
  34  * The localized time zone names available from the implementations of
  35  * this class are also the source for the
  36  * {@link java.text.DateFormatSymbols#getZoneStrings()
  37  * DateFormatSymbols.getZoneStrings()} method.
  38  *
  39  * @since        1.6
  40  */
  41 public abstract class TimeZoneNameProvider extends LocaleServiceProvider {
  42 
  43     /**
  44      * Sole constructor.  (For invocation by subclass constructors, typically
  45      * implicit.)
  46      */
  47     protected TimeZoneNameProvider() {
  48     }
  49 
  50     /**
  51      * Returns a name for the given time zone ID that's suitable for
  52      * presentation to the user in the specified locale. The given time
  53      * zone ID is "GMT" or one of the names defined using "Zone" entries
  54      * in the "tz database", a public domain time zone database at
  55      * <a href="https://www.iana.org/time-zones">https://www.iana.org/time-zones</a>.
  56      * The data of this database is contained in a file whose name starts with
  57      * "tzdata", and the specification of the data format is part of the zic.8
  58      * man page, which is contained in a file whose name starts with "tzcode".
  59      * <p>
  60      * If <code>daylight</code> is true, the method should return a name
  61      * appropriate for daylight saving time even if the specified time zone
  62      * has not observed daylight saving time in the past.
  63      *
  64      * @param ID a time zone ID string
  65      * @param daylight if true, return the daylight saving name.
  66      * @param style either {@link java.util.TimeZone#LONG TimeZone.LONG} or
  67      *    {@link java.util.TimeZone#SHORT TimeZone.SHORT}
  68      * @param locale the desired locale
  69      * @return the human-readable name of the given time zone in the
  70      *     given locale, or null if it's not available.
  71      * @exception IllegalArgumentException if <code>style</code> is invalid,
  72      *     or <code>locale</code> isn't one of the locales returned from
  73      *     {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
  74      *     getAvailableLocales()}.
  75      * @exception NullPointerException if <code>ID</code> or <code>locale</code>
  76      *     is null
  77      * @see java.util.TimeZone#getDisplayName(boolean, int, java.util.Locale)
  78      */
  79     public abstract String getDisplayName(String ID, boolean daylight, int style, Locale locale);
  80 
  81     /**
  82      * Returns a generic name for the given time zone {@code ID} that's suitable
  83      * for presentation to the user in the specified {@code locale}. Generic
  84      * time zone names are neutral from standard time and daylight saving
  85      * time. For example, "PT" is the short generic name of time zone ID {@code
  86      * America/Los_Angeles}, while its short standard time and daylight saving
  87      * time names are "PST" and "PDT", respectively. Refer to
  88      * {@link #getDisplayName(String, boolean, int, Locale) getDisplayName}
  89      * for valid time zone IDs.
  90      *
  91      * <p>The default implementation of this method returns {@code null}.
  92      *
  93      * @param ID a time zone ID string
  94      * @param style either {@link java.util.TimeZone#LONG TimeZone.LONG} or
  95      *    {@link java.util.TimeZone#SHORT TimeZone.SHORT}
  96      * @param locale the desired locale
  97      * @return the human-readable generic name of the given time zone in the
  98      *     given locale, or {@code null} if it's not available.
  99      * @exception IllegalArgumentException if <code>style</code> is invalid,
 100      *     or <code>locale</code> isn't one of the locales returned from
 101      *     {@link LocaleServiceProvider#getAvailableLocales()
 102      *     getAvailableLocales()}.
 103      * @exception NullPointerException if <code>ID</code> or <code>locale</code>
 104      *     is {@code null}
 105      * @since 1.8
 106      */
 107     public String getGenericDisplayName(String ID, int style, Locale locale) {
 108         return null;
 109     }
 110 }