< prev index next >

src/java.base/share/classes/java/util/TimeZone.java

Print this page
rev 56290 : 8230648: Replace @exception tag with @throws in java.base
Summary: Minor coding style update of javadoc tag in any file in java.base
Reviewed-by: prappo, lancea


 312      * @see #getDisplayName(boolean, int, Locale)
 313      * @see Locale#getDefault(Locale.Category)
 314      * @see Locale.Category
 315      */
 316     public final String getDisplayName() {
 317         return getDisplayName(false, LONG,
 318                               Locale.getDefault(Locale.Category.DISPLAY));
 319     }
 320 
 321     /**
 322      * Returns a long standard time name of this {@code TimeZone} suitable for
 323      * presentation to the user in the specified {@code locale}.
 324      *
 325      * <p>This method is equivalent to:
 326      * <blockquote><pre>
 327      * getDisplayName(false, {@link #LONG}, locale)
 328      * </pre></blockquote>
 329      *
 330      * @param locale the locale in which to supply the display name.
 331      * @return the human-readable name of this time zone in the given locale.
 332      * @exception NullPointerException if {@code locale} is {@code null}.
 333      * @since 1.2
 334      * @see #getDisplayName(boolean, int, Locale)
 335      */
 336     public final String getDisplayName(Locale locale) {
 337         return getDisplayName(false, LONG, locale);
 338     }
 339 
 340     /**
 341      * Returns a name in the specified {@code style} of this {@code TimeZone}
 342      * suitable for presentation to the user in the default locale. If the
 343      * specified {@code daylight} is {@code true}, a Daylight Saving Time name
 344      * is returned (even if this {@code TimeZone} doesn't observe Daylight Saving
 345      * Time). Otherwise, a Standard Time name is returned.
 346      *
 347      * <p>This method is equivalent to:
 348      * <blockquote><pre>
 349      * getDisplayName(daylight, style,
 350      *                Locale.getDefault({@link Locale.Category#DISPLAY}))
 351      * </pre></blockquote>
 352      *
 353      * @param daylight {@code true} specifying a Daylight Saving Time name, or
 354      *                 {@code false} specifying a Standard Time name
 355      * @param style either {@link #LONG} or {@link #SHORT}
 356      * @return the human-readable name of this time zone in the default locale.
 357      * @exception IllegalArgumentException if {@code style} is invalid.
 358      * @since 1.2
 359      * @see #getDisplayName(boolean, int, Locale)
 360      * @see Locale#getDefault(Locale.Category)
 361      * @see Locale.Category
 362      * @see java.text.DateFormatSymbols#getZoneStrings()
 363      */
 364     public final String getDisplayName(boolean daylight, int style) {
 365         return getDisplayName(daylight, style,
 366                               Locale.getDefault(Locale.Category.DISPLAY));
 367     }
 368 
 369     /**
 370      * Returns a name in the specified {@code style} of this {@code TimeZone}
 371      * suitable for presentation to the user in the specified {@code
 372      * locale}. If the specified {@code daylight} is {@code true}, a Daylight
 373      * Saving Time name is returned (even if this {@code TimeZone} doesn't
 374      * observe Daylight Saving Time). Otherwise, a Standard Time name is
 375      * returned.
 376      *
 377      * <p>When looking up a time zone name, the {@linkplain
 378      * ResourceBundle.Control#getCandidateLocales(String,Locale) default
 379      * <code>Locale</code> search path of <code>ResourceBundle</code>} derived
 380      * from the specified {@code locale} is used. (No {@linkplain
 381      * ResourceBundle.Control#getFallbackLocale(String,Locale) fallback
 382      * <code>Locale</code>} search is performed.) If a time zone name in any
 383      * {@code Locale} of the search path, including {@link Locale#ROOT}, is
 384      * found, the name is returned. Otherwise, a string in the
 385      * <a href="#NormalizedCustomID">normalized custom ID format</a> is returned.
 386      *
 387      * @param daylight {@code true} specifying a Daylight Saving Time name, or
 388      *                 {@code false} specifying a Standard Time name
 389      * @param style either {@link #LONG} or {@link #SHORT}
 390      * @param locale   the locale in which to supply the display name.
 391      * @return the human-readable name of this time zone in the given locale.
 392      * @exception IllegalArgumentException if {@code style} is invalid.
 393      * @exception NullPointerException if {@code locale} is {@code null}.
 394      * @since 1.2
 395      * @see java.text.DateFormatSymbols#getZoneStrings()
 396      */
 397     public String getDisplayName(boolean daylight, int style, Locale locale) {
 398         if (style != SHORT && style != LONG) {
 399             throw new IllegalArgumentException("Illegal style: " + style);
 400         }
 401         String id = getID();
 402         String name = TimeZoneNameUtility.retrieveDisplayName(id, daylight, style, locale);
 403         if (name != null) {
 404             return name;
 405         }
 406 
 407         if (id.startsWith("GMT") && id.length() > 3) {
 408             char sign = id.charAt(3);
 409             if (sign == '+' || sign == '-') {
 410                 return id;
 411             }
 412         }
 413         int offset = getRawOffset();




 312      * @see #getDisplayName(boolean, int, Locale)
 313      * @see Locale#getDefault(Locale.Category)
 314      * @see Locale.Category
 315      */
 316     public final String getDisplayName() {
 317         return getDisplayName(false, LONG,
 318                               Locale.getDefault(Locale.Category.DISPLAY));
 319     }
 320 
 321     /**
 322      * Returns a long standard time name of this {@code TimeZone} suitable for
 323      * presentation to the user in the specified {@code locale}.
 324      *
 325      * <p>This method is equivalent to:
 326      * <blockquote><pre>
 327      * getDisplayName(false, {@link #LONG}, locale)
 328      * </pre></blockquote>
 329      *
 330      * @param locale the locale in which to supply the display name.
 331      * @return the human-readable name of this time zone in the given locale.
 332      * @throws    NullPointerException if {@code locale} is {@code null}.
 333      * @since 1.2
 334      * @see #getDisplayName(boolean, int, Locale)
 335      */
 336     public final String getDisplayName(Locale locale) {
 337         return getDisplayName(false, LONG, locale);
 338     }
 339 
 340     /**
 341      * Returns a name in the specified {@code style} of this {@code TimeZone}
 342      * suitable for presentation to the user in the default locale. If the
 343      * specified {@code daylight} is {@code true}, a Daylight Saving Time name
 344      * is returned (even if this {@code TimeZone} doesn't observe Daylight Saving
 345      * Time). Otherwise, a Standard Time name is returned.
 346      *
 347      * <p>This method is equivalent to:
 348      * <blockquote><pre>
 349      * getDisplayName(daylight, style,
 350      *                Locale.getDefault({@link Locale.Category#DISPLAY}))
 351      * </pre></blockquote>
 352      *
 353      * @param daylight {@code true} specifying a Daylight Saving Time name, or
 354      *                 {@code false} specifying a Standard Time name
 355      * @param style either {@link #LONG} or {@link #SHORT}
 356      * @return the human-readable name of this time zone in the default locale.
 357      * @throws    IllegalArgumentException if {@code style} is invalid.
 358      * @since 1.2
 359      * @see #getDisplayName(boolean, int, Locale)
 360      * @see Locale#getDefault(Locale.Category)
 361      * @see Locale.Category
 362      * @see java.text.DateFormatSymbols#getZoneStrings()
 363      */
 364     public final String getDisplayName(boolean daylight, int style) {
 365         return getDisplayName(daylight, style,
 366                               Locale.getDefault(Locale.Category.DISPLAY));
 367     }
 368 
 369     /**
 370      * Returns a name in the specified {@code style} of this {@code TimeZone}
 371      * suitable for presentation to the user in the specified {@code
 372      * locale}. If the specified {@code daylight} is {@code true}, a Daylight
 373      * Saving Time name is returned (even if this {@code TimeZone} doesn't
 374      * observe Daylight Saving Time). Otherwise, a Standard Time name is
 375      * returned.
 376      *
 377      * <p>When looking up a time zone name, the {@linkplain
 378      * ResourceBundle.Control#getCandidateLocales(String,Locale) default
 379      * <code>Locale</code> search path of <code>ResourceBundle</code>} derived
 380      * from the specified {@code locale} is used. (No {@linkplain
 381      * ResourceBundle.Control#getFallbackLocale(String,Locale) fallback
 382      * <code>Locale</code>} search is performed.) If a time zone name in any
 383      * {@code Locale} of the search path, including {@link Locale#ROOT}, is
 384      * found, the name is returned. Otherwise, a string in the
 385      * <a href="#NormalizedCustomID">normalized custom ID format</a> is returned.
 386      *
 387      * @param daylight {@code true} specifying a Daylight Saving Time name, or
 388      *                 {@code false} specifying a Standard Time name
 389      * @param style either {@link #LONG} or {@link #SHORT}
 390      * @param locale   the locale in which to supply the display name.
 391      * @return the human-readable name of this time zone in the given locale.
 392      * @throws    IllegalArgumentException if {@code style} is invalid.
 393      * @throws    NullPointerException if {@code locale} is {@code null}.
 394      * @since 1.2
 395      * @see java.text.DateFormatSymbols#getZoneStrings()
 396      */
 397     public String getDisplayName(boolean daylight, int style, Locale locale) {
 398         if (style != SHORT && style != LONG) {
 399             throw new IllegalArgumentException("Illegal style: " + style);
 400         }
 401         String id = getID();
 402         String name = TimeZoneNameUtility.retrieveDisplayName(id, daylight, style, locale);
 403         if (name != null) {
 404             return name;
 405         }
 406 
 407         if (id.startsWith("GMT") && id.length() > 3) {
 408             char sign = id.charAt(3);
 409             if (sign == '+' || sign == '-') {
 410                 return id;
 411             }
 412         }
 413         int offset = getRawOffset();


< prev index next >