Java Code Examples for sun.util.locale.provider.TimeZoneNameUtility#retrieveDisplayName()
The following examples show how to use
sun.util.locale.provider.TimeZoneNameUtility#retrieveDisplayName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimpleDateFormat.java From Bytecoder with Apache License 2.0 | 6 votes |
private int matchZoneString(String text, int start, String[] zoneNames) { for (int i = 1; i <= 4; ++i) { // Checking long and short zones [1 & 2], // and long and short daylight [3 & 4]. String zoneName = zoneNames[i]; if (zoneName.isEmpty()) { // fill in by retrieving single name zoneName = TimeZoneNameUtility.retrieveDisplayName( zoneNames[0], i >= 3, i % 2, locale); zoneNames[i] = zoneName; } if (text.regionMatches(true, start, zoneName, 0, zoneName.length())) { return i; } } return -1; }
Example 2
Source File: TimeZone.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * Returns a name in the specified {@code style} of this {@code TimeZone} * suitable for presentation to the user in the specified {@code * locale}. If the specified {@code daylight} is {@code true}, a Daylight * Saving Time name is returned (even if this {@code TimeZone} doesn't * observe Daylight Saving Time). Otherwise, a Standard Time name is * returned. * * <p>When looking up a time zone name, the {@linkplain * ResourceBundle.Control#getCandidateLocales(String,Locale) default * <code>Locale</code> search path of <code>ResourceBundle</code>} derived * from the specified {@code locale} is used. (No {@linkplain * ResourceBundle.Control#getFallbackLocale(String,Locale) fallback * <code>Locale</code>} search is performed.) If a time zone name in any * {@code Locale} of the search path, including {@link Locale#ROOT}, is * found, the name is returned. Otherwise, a string in the * <a href="#NormalizedCustomID">normalized custom ID format</a> is returned. * * @param daylight {@code true} specifying a Daylight Saving Time name, or * {@code false} specifying a Standard Time name * @param style either {@link #LONG} or {@link #SHORT} * @param locale the locale in which to supply the display name. * @return the human-readable name of this time zone in the given locale. * @exception IllegalArgumentException if {@code style} is invalid. * @exception NullPointerException if {@code locale} is {@code null}. * @since 1.2 * @see java.text.DateFormatSymbols#getZoneStrings() */ public String getDisplayName(boolean daylight, int style, Locale locale) { if (style != SHORT && style != LONG) { throw new IllegalArgumentException("Illegal style: " + style); } String id = getID(); String name = TimeZoneNameUtility.retrieveDisplayName(id, daylight, style, locale); if (name != null) { return name; } if (id.startsWith("GMT") && id.length() > 3) { char sign = id.charAt(3); if (sign == '+' || sign == '-') { return id; } } int offset = getRawOffset(); if (daylight) { offset += getDSTSavings(); } return ZoneInfoFile.toCustomID(offset); }
Example 3
Source File: TimeZone.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
/** * Returns a name in the specified {@code style} of this {@code TimeZone} * suitable for presentation to the user in the specified {@code * locale}. If the specified {@code daylight} is {@code true}, a Daylight * Saving Time name is returned (even if this {@code TimeZone} doesn't * observe Daylight Saving Time). Otherwise, a Standard Time name is * returned. * * <p>When looking up a time zone name, the {@linkplain * ResourceBundle.Control#getCandidateLocales(String,Locale) default * <code>Locale</code> search path of <code>ResourceBundle</code>} derived * from the specified {@code locale} is used. (No {@linkplain * ResourceBundle.Control#getFallbackLocale(String,Locale) fallback * <code>Locale</code>} search is performed.) If a time zone name in any * {@code Locale} of the search path, including {@link Locale#ROOT}, is * found, the name is returned. Otherwise, a string in the * <a href="#NormalizedCustomID">normalized custom ID format</a> is returned. * * @param daylight {@code true} specifying a Daylight Saving Time name, or * {@code false} specifying a Standard Time name * @param style either {@link #LONG} or {@link #SHORT} * @param locale the locale in which to supply the display name. * @return the human-readable name of this time zone in the given locale. * @exception IllegalArgumentException if {@code style} is invalid. * @exception NullPointerException if {@code locale} is {@code null}. * @since 1.2 * @see java.text.DateFormatSymbols#getZoneStrings() */ public String getDisplayName(boolean daylight, int style, Locale locale) { if (style != SHORT && style != LONG) { throw new IllegalArgumentException("Illegal style: " + style); } String id = getID(); String name = TimeZoneNameUtility.retrieveDisplayName(id, daylight, style, locale); if (name != null) { return name; } if (id.startsWith("GMT") && id.length() > 3) { char sign = id.charAt(3); if (sign == '+' || sign == '-') { return id; } } int offset = getRawOffset(); if (daylight) { offset += getDSTSavings(); } return ZoneInfoFile.toCustomID(offset); }
Example 4
Source File: TimeZone.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * Returns a name in the specified {@code style} of this {@code TimeZone} * suitable for presentation to the user in the specified {@code * locale}. If the specified {@code daylight} is {@code true}, a Daylight * Saving Time name is returned (even if this {@code TimeZone} doesn't * observe Daylight Saving Time). Otherwise, a Standard Time name is * returned. * * <p>When looking up a time zone name, the {@linkplain * ResourceBundle.Control#getCandidateLocales(String,Locale) default * <code>Locale</code> search path of <code>ResourceBundle</code>} derived * from the specified {@code locale} is used. (No {@linkplain * ResourceBundle.Control#getFallbackLocale(String,Locale) fallback * <code>Locale</code>} search is performed.) If a time zone name in any * {@code Locale} of the search path, including {@link Locale#ROOT}, is * found, the name is returned. Otherwise, a string in the * <a href="#NormalizedCustomID">normalized custom ID format</a> is returned. * * @param daylight {@code true} specifying a Daylight Saving Time name, or * {@code false} specifying a Standard Time name * @param style either {@link #LONG} or {@link #SHORT} * @param locale the locale in which to supply the display name. * @return the human-readable name of this time zone in the given locale. * @exception IllegalArgumentException if {@code style} is invalid. * @exception NullPointerException if {@code locale} is {@code null}. * @since 1.2 * @see java.text.DateFormatSymbols#getZoneStrings() */ public String getDisplayName(boolean daylight, int style, Locale locale) { if (style != SHORT && style != LONG) { throw new IllegalArgumentException("Illegal style: " + style); } String id = getID(); String name = TimeZoneNameUtility.retrieveDisplayName(id, daylight, style, locale); if (name != null) { return name; } if (id.startsWith("GMT") && id.length() > 3) { char sign = id.charAt(3); if (sign == '+' || sign == '-') { return id; } } int offset = getRawOffset(); if (daylight) { offset += getDSTSavings(); } return ZoneInfoFile.toCustomID(offset); }
Example 5
Source File: TimeZone.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
/** * Returns a name in the specified {@code style} of this {@code TimeZone} * suitable for presentation to the user in the specified {@code * locale}. If the specified {@code daylight} is {@code true}, a Daylight * Saving Time name is returned (even if this {@code TimeZone} doesn't * observe Daylight Saving Time). Otherwise, a Standard Time name is * returned. * * <p>When looking up a time zone name, the {@linkplain * ResourceBundle.Control#getCandidateLocales(String,Locale) default * <code>Locale</code> search path of <code>ResourceBundle</code>} derived * from the specified {@code locale} is used. (No {@linkplain * ResourceBundle.Control#getFallbackLocale(String,Locale) fallback * <code>Locale</code>} search is performed.) If a time zone name in any * {@code Locale} of the search path, including {@link Locale#ROOT}, is * found, the name is returned. Otherwise, a string in the * <a href="#NormalizedCustomID">normalized custom ID format</a> is returned. * * @param daylight {@code true} specifying a Daylight Saving Time name, or * {@code false} specifying a Standard Time name * @param style either {@link #LONG} or {@link #SHORT} * @param locale the locale in which to supply the display name. * @return the human-readable name of this time zone in the given locale. * @exception IllegalArgumentException if {@code style} is invalid. * @exception NullPointerException if {@code locale} is {@code null}. * @since 1.2 * @see java.text.DateFormatSymbols#getZoneStrings() */ public String getDisplayName(boolean daylight, int style, Locale locale) { if (style != SHORT && style != LONG) { throw new IllegalArgumentException("Illegal style: " + style); } String id = getID(); String name = TimeZoneNameUtility.retrieveDisplayName(id, daylight, style, locale); if (name != null) { return name; } if (id.startsWith("GMT") && id.length() > 3) { char sign = id.charAt(3); if (sign == '+' || sign == '-') { return id; } } int offset = getRawOffset(); if (daylight) { offset += getDSTSavings(); } return ZoneInfoFile.toCustomID(offset); }
Example 6
Source File: TimeZone.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** * Returns a name in the specified {@code style} of this {@code TimeZone} * suitable for presentation to the user in the specified {@code * locale}. If the specified {@code daylight} is {@code true}, a Daylight * Saving Time name is returned (even if this {@code TimeZone} doesn't * observe Daylight Saving Time). Otherwise, a Standard Time name is * returned. * * <p>When looking up a time zone name, the {@linkplain * ResourceBundle.Control#getCandidateLocales(String,Locale) default * <code>Locale</code> search path of <code>ResourceBundle</code>} derived * from the specified {@code locale} is used. (No {@linkplain * ResourceBundle.Control#getFallbackLocale(String,Locale) fallback * <code>Locale</code>} search is performed.) If a time zone name in any * {@code Locale} of the search path, including {@link Locale#ROOT}, is * found, the name is returned. Otherwise, a string in the * <a href="#NormalizedCustomID">normalized custom ID format</a> is returned. * * @param daylight {@code true} specifying a Daylight Saving Time name, or * {@code false} specifying a Standard Time name * @param style either {@link #LONG} or {@link #SHORT} * @param locale the locale in which to supply the display name. * @return the human-readable name of this time zone in the given locale. * @exception IllegalArgumentException if {@code style} is invalid. * @exception NullPointerException if {@code locale} is {@code null}. * @since 1.2 * @see java.text.DateFormatSymbols#getZoneStrings() */ public String getDisplayName(boolean daylight, int style, Locale locale) { if (style != SHORT && style != LONG) { throw new IllegalArgumentException("Illegal style: " + style); } String id = getID(); String name = TimeZoneNameUtility.retrieveDisplayName(id, daylight, style, locale); if (name != null) { return name; } if (id.startsWith("GMT") && id.length() > 3) { char sign = id.charAt(3); if (sign == '+' || sign == '-') { return id; } } int offset = getRawOffset(); if (daylight) { offset += getDSTSavings(); } return ZoneInfoFile.toCustomID(offset); }
Example 7
Source File: TimeZone.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * Returns a name in the specified {@code style} of this {@code TimeZone} * suitable for presentation to the user in the specified {@code * locale}. If the specified {@code daylight} is {@code true}, a Daylight * Saving Time name is returned (even if this {@code TimeZone} doesn't * observe Daylight Saving Time). Otherwise, a Standard Time name is * returned. * * <p>When looking up a time zone name, the {@linkplain * ResourceBundle.Control#getCandidateLocales(String,Locale) default * <code>Locale</code> search path of <code>ResourceBundle</code>} derived * from the specified {@code locale} is used. (No {@linkplain * ResourceBundle.Control#getFallbackLocale(String,Locale) fallback * <code>Locale</code>} search is performed.) If a time zone name in any * {@code Locale} of the search path, including {@link Locale#ROOT}, is * found, the name is returned. Otherwise, a string in the * <a href="#NormalizedCustomID">normalized custom ID format</a> is returned. * * @param daylight {@code true} specifying a Daylight Saving Time name, or * {@code false} specifying a Standard Time name * @param style either {@link #LONG} or {@link #SHORT} * @param locale the locale in which to supply the display name. * @return the human-readable name of this time zone in the given locale. * @exception IllegalArgumentException if {@code style} is invalid. * @exception NullPointerException if {@code locale} is {@code null}. * @since 1.2 * @see java.text.DateFormatSymbols#getZoneStrings() */ public String getDisplayName(boolean daylight, int style, Locale locale) { if (style != SHORT && style != LONG) { throw new IllegalArgumentException("Illegal style: " + style); } String id = getID(); String name = TimeZoneNameUtility.retrieveDisplayName(id, daylight, style, locale); if (name != null) { return name; } if (id.startsWith("GMT") && id.length() > 3) { char sign = id.charAt(3); if (sign == '+' || sign == '-') { return id; } } int offset = getRawOffset(); if (daylight) { offset += getDSTSavings(); } return ZoneInfoFile.toCustomID(offset); }
Example 8
Source File: TimeZone.java From hottub with GNU General Public License v2.0 | 4 votes |
/** * Returns a name in the specified {@code style} of this {@code TimeZone} * suitable for presentation to the user in the specified {@code * locale}. If the specified {@code daylight} is {@code true}, a Daylight * Saving Time name is returned (even if this {@code TimeZone} doesn't * observe Daylight Saving Time). Otherwise, a Standard Time name is * returned. * * <p>When looking up a time zone name, the {@linkplain * ResourceBundle.Control#getCandidateLocales(String,Locale) default * <code>Locale</code> search path of <code>ResourceBundle</code>} derived * from the specified {@code locale} is used. (No {@linkplain * ResourceBundle.Control#getFallbackLocale(String,Locale) fallback * <code>Locale</code>} search is performed.) If a time zone name in any * {@code Locale} of the search path, including {@link Locale#ROOT}, is * found, the name is returned. Otherwise, a string in the * <a href="#NormalizedCustomID">normalized custom ID format</a> is returned. * * @param daylight {@code true} specifying a Daylight Saving Time name, or * {@code false} specifying a Standard Time name * @param style either {@link #LONG} or {@link #SHORT} * @param locale the locale in which to supply the display name. * @return the human-readable name of this time zone in the given locale. * @exception IllegalArgumentException if {@code style} is invalid. * @exception NullPointerException if {@code locale} is {@code null}. * @since 1.2 * @see java.text.DateFormatSymbols#getZoneStrings() */ public String getDisplayName(boolean daylight, int style, Locale locale) { if (style != SHORT && style != LONG) { throw new IllegalArgumentException("Illegal style: " + style); } String id = getID(); String name = TimeZoneNameUtility.retrieveDisplayName(id, daylight, style, locale); if (name != null) { return name; } if (id.startsWith("GMT") && id.length() > 3) { char sign = id.charAt(3); if (sign == '+' || sign == '-') { return id; } } int offset = getRawOffset(); if (daylight) { offset += getDSTSavings(); } return ZoneInfoFile.toCustomID(offset); }
Example 9
Source File: TimeZone.java From Java8CN with Apache License 2.0 | 4 votes |
/** * Returns a name in the specified {@code style} of this {@code TimeZone} * suitable for presentation to the user in the specified {@code * locale}. If the specified {@code daylight} is {@code true}, a Daylight * Saving Time name is returned (even if this {@code TimeZone} doesn't * observe Daylight Saving Time). Otherwise, a Standard Time name is * returned. * * <p>When looking up a time zone name, the {@linkplain * ResourceBundle.Control#getCandidateLocales(String,Locale) default * <code>Locale</code> search path of <code>ResourceBundle</code>} derived * from the specified {@code locale} is used. (No {@linkplain * ResourceBundle.Control#getFallbackLocale(String,Locale) fallback * <code>Locale</code>} search is performed.) If a time zone name in any * {@code Locale} of the search path, including {@link Locale#ROOT}, is * found, the name is returned. Otherwise, a string in the * <a href="#NormalizedCustomID">normalized custom ID format</a> is returned. * * @param daylight {@code true} specifying a Daylight Saving Time name, or * {@code false} specifying a Standard Time name * @param style either {@link #LONG} or {@link #SHORT} * @param locale the locale in which to supply the display name. * @return the human-readable name of this time zone in the given locale. * @exception IllegalArgumentException if {@code style} is invalid. * @exception NullPointerException if {@code locale} is {@code null}. * @since 1.2 * @see java.text.DateFormatSymbols#getZoneStrings() */ public String getDisplayName(boolean daylight, int style, Locale locale) { if (style != SHORT && style != LONG) { throw new IllegalArgumentException("Illegal style: " + style); } String id = getID(); String name = TimeZoneNameUtility.retrieveDisplayName(id, daylight, style, locale); if (name != null) { return name; } if (id.startsWith("GMT") && id.length() > 3) { char sign = id.charAt(3); if (sign == '+' || sign == '-') { return id; } } int offset = getRawOffset(); if (daylight) { offset += getDSTSavings(); } return ZoneInfoFile.toCustomID(offset); }
Example 10
Source File: TimeZone.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * Returns a name in the specified {@code style} of this {@code TimeZone} * suitable for presentation to the user in the specified {@code * locale}. If the specified {@code daylight} is {@code true}, a Daylight * Saving Time name is returned (even if this {@code TimeZone} doesn't * observe Daylight Saving Time). Otherwise, a Standard Time name is * returned. * * <p>When looking up a time zone name, the {@linkplain * ResourceBundle.Control#getCandidateLocales(String,Locale) default * <code>Locale</code> search path of <code>ResourceBundle</code>} derived * from the specified {@code locale} is used. (No {@linkplain * ResourceBundle.Control#getFallbackLocale(String,Locale) fallback * <code>Locale</code>} search is performed.) If a time zone name in any * {@code Locale} of the search path, including {@link Locale#ROOT}, is * found, the name is returned. Otherwise, a string in the * <a href="#NormalizedCustomID">normalized custom ID format</a> is returned. * * @param daylight {@code true} specifying a Daylight Saving Time name, or * {@code false} specifying a Standard Time name * @param style either {@link #LONG} or {@link #SHORT} * @param locale the locale in which to supply the display name. * @return the human-readable name of this time zone in the given locale. * @exception IllegalArgumentException if {@code style} is invalid. * @exception NullPointerException if {@code locale} is {@code null}. * @since 1.2 * @see java.text.DateFormatSymbols#getZoneStrings() */ public String getDisplayName(boolean daylight, int style, Locale locale) { if (style != SHORT && style != LONG) { throw new IllegalArgumentException("Illegal style: " + style); } String id = getID(); String name = TimeZoneNameUtility.retrieveDisplayName(id, daylight, style, locale); if (name != null) { return name; } if (id.startsWith("GMT") && id.length() > 3) { char sign = id.charAt(3); if (sign == '+' || sign == '-') { return id; } } int offset = getRawOffset(); if (daylight) { offset += getDSTSavings(); } return ZoneInfoFile.toCustomID(offset); }
Example 11
Source File: TimeZone.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
/** * Returns a name in the specified {@code style} of this {@code TimeZone} * suitable for presentation to the user in the specified {@code * locale}. If the specified {@code daylight} is {@code true}, a Daylight * Saving Time name is returned (even if this {@code TimeZone} doesn't * observe Daylight Saving Time). Otherwise, a Standard Time name is * returned. * * <p>When looking up a time zone name, the {@linkplain * ResourceBundle.Control#getCandidateLocales(String,Locale) default * <code>Locale</code> search path of <code>ResourceBundle</code>} derived * from the specified {@code locale} is used. (No {@linkplain * ResourceBundle.Control#getFallbackLocale(String,Locale) fallback * <code>Locale</code>} search is performed.) If a time zone name in any * {@code Locale} of the search path, including {@link Locale#ROOT}, is * found, the name is returned. Otherwise, a string in the * <a href="#NormalizedCustomID">normalized custom ID format</a> is returned. * * @param daylight {@code true} specifying a Daylight Saving Time name, or * {@code false} specifying a Standard Time name * @param style either {@link #LONG} or {@link #SHORT} * @param locale the locale in which to supply the display name. * @return the human-readable name of this time zone in the given locale. * @exception IllegalArgumentException if {@code style} is invalid. * @exception NullPointerException if {@code locale} is {@code null}. * @since 1.2 * @see java.text.DateFormatSymbols#getZoneStrings() */ public String getDisplayName(boolean daylight, int style, Locale locale) { if (style != SHORT && style != LONG) { throw new IllegalArgumentException("Illegal style: " + style); } String id = getID(); String name = TimeZoneNameUtility.retrieveDisplayName(id, daylight, style, locale); if (name != null) { return name; } if (id.startsWith("GMT") && id.length() > 3) { char sign = id.charAt(3); if (sign == '+' || sign == '-') { return id; } } int offset = getRawOffset(); if (daylight) { offset += getDSTSavings(); } return ZoneInfoFile.toCustomID(offset); }
Example 12
Source File: TimeZone.java From Bytecoder with Apache License 2.0 | 4 votes |
/** * Returns a name in the specified {@code style} of this {@code TimeZone} * suitable for presentation to the user in the specified {@code * locale}. If the specified {@code daylight} is {@code true}, a Daylight * Saving Time name is returned (even if this {@code TimeZone} doesn't * observe Daylight Saving Time). Otherwise, a Standard Time name is * returned. * * <p>When looking up a time zone name, the {@linkplain * ResourceBundle.Control#getCandidateLocales(String,Locale) default * {@code Locale} search path of {@code ResourceBundle}} derived * from the specified {@code locale} is used. (No {@linkplain * ResourceBundle.Control#getFallbackLocale(String,Locale) fallback * {@code Locale}} search is performed.) If a time zone name in any * {@code Locale} of the search path, including {@link Locale#ROOT}, is * found, the name is returned. Otherwise, a string in the * <a href="#NormalizedCustomID">normalized custom ID format</a> is returned. * * @param daylight {@code true} specifying a Daylight Saving Time name, or * {@code false} specifying a Standard Time name * @param style either {@link #LONG} or {@link #SHORT} * @param locale the locale in which to supply the display name. * @return the human-readable name of this time zone in the given locale. * @throws IllegalArgumentException if {@code style} is invalid. * @throws NullPointerException if {@code locale} is {@code null}. * @since 1.2 * @see java.text.DateFormatSymbols#getZoneStrings() */ public String getDisplayName(boolean daylight, int style, Locale locale) { if (style != SHORT && style != LONG) { throw new IllegalArgumentException("Illegal style: " + style); } String id = getID(); String name = TimeZoneNameUtility.retrieveDisplayName(id, daylight, style, locale); if (name != null) { return name; } if (id.startsWith("GMT") && id.length() > 3) { char sign = id.charAt(3); if (sign == '+' || sign == '-') { return id; } } int offset = getRawOffset(); if (daylight) { offset += getDSTSavings(); } return ZoneInfoFile.toCustomID(offset); }
Example 13
Source File: TimeZone.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * Returns a name in the specified {@code style} of this {@code TimeZone} * suitable for presentation to the user in the specified {@code * locale}. If the specified {@code daylight} is {@code true}, a Daylight * Saving Time name is returned (even if this {@code TimeZone} doesn't * observe Daylight Saving Time). Otherwise, a Standard Time name is * returned. * * <p>When looking up a time zone name, the {@linkplain * ResourceBundle.Control#getCandidateLocales(String,Locale) default * <code>Locale</code> search path of <code>ResourceBundle</code>} derived * from the specified {@code locale} is used. (No {@linkplain * ResourceBundle.Control#getFallbackLocale(String,Locale) fallback * <code>Locale</code>} search is performed.) If a time zone name in any * {@code Locale} of the search path, including {@link Locale#ROOT}, is * found, the name is returned. Otherwise, a string in the * <a href="#NormalizedCustomID">normalized custom ID format</a> is returned. * * @param daylight {@code true} specifying a Daylight Saving Time name, or * {@code false} specifying a Standard Time name * @param style either {@link #LONG} or {@link #SHORT} * @param locale the locale in which to supply the display name. * @return the human-readable name of this time zone in the given locale. * @exception IllegalArgumentException if {@code style} is invalid. * @exception NullPointerException if {@code locale} is {@code null}. * @since 1.2 * @see java.text.DateFormatSymbols#getZoneStrings() */ public String getDisplayName(boolean daylight, int style, Locale locale) { if (style != SHORT && style != LONG) { throw new IllegalArgumentException("Illegal style: " + style); } String id = getID(); String name = TimeZoneNameUtility.retrieveDisplayName(id, daylight, style, locale); if (name != null) { return name; } if (id.startsWith("GMT") && id.length() > 3) { char sign = id.charAt(3); if (sign == '+' || sign == '-') { return id; } } int offset = getRawOffset(); if (daylight) { offset += getDSTSavings(); } return ZoneInfoFile.toCustomID(offset); }
Example 14
Source File: TimeZone.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * Returns a name in the specified {@code style} of this {@code TimeZone} * suitable for presentation to the user in the specified {@code * locale}. If the specified {@code daylight} is {@code true}, a Daylight * Saving Time name is returned (even if this {@code TimeZone} doesn't * observe Daylight Saving Time). Otherwise, a Standard Time name is * returned. * * <p>When looking up a time zone name, the {@linkplain * ResourceBundle.Control#getCandidateLocales(String,Locale) default * <code>Locale</code> search path of <code>ResourceBundle</code>} derived * from the specified {@code locale} is used. (No {@linkplain * ResourceBundle.Control#getFallbackLocale(String,Locale) fallback * <code>Locale</code>} search is performed.) If a time zone name in any * {@code Locale} of the search path, including {@link Locale#ROOT}, is * found, the name is returned. Otherwise, a string in the * <a href="#NormalizedCustomID">normalized custom ID format</a> is returned. * * @param daylight {@code true} specifying a Daylight Saving Time name, or * {@code false} specifying a Standard Time name * @param style either {@link #LONG} or {@link #SHORT} * @param locale the locale in which to supply the display name. * @return the human-readable name of this time zone in the given locale. * @exception IllegalArgumentException if {@code style} is invalid. * @exception NullPointerException if {@code locale} is {@code null}. * @since 1.2 * @see java.text.DateFormatSymbols#getZoneStrings() */ public String getDisplayName(boolean daylight, int style, Locale locale) { if (style != SHORT && style != LONG) { throw new IllegalArgumentException("Illegal style: " + style); } String id = getID(); String name = TimeZoneNameUtility.retrieveDisplayName(id, daylight, style, locale); if (name != null) { return name; } if (id.startsWith("GMT") && id.length() > 3) { char sign = id.charAt(3); if (sign == '+' || sign == '-') { return id; } } int offset = getRawOffset(); if (daylight) { offset += getDSTSavings(); } return ZoneInfoFile.toCustomID(offset); }
Example 15
Source File: TimeZone.java From JDKSourceCode1.8 with MIT License | 4 votes |
/** * Returns a name in the specified {@code style} of this {@code TimeZone} * suitable for presentation to the user in the specified {@code * locale}. If the specified {@code daylight} is {@code true}, a Daylight * Saving Time name is returned (even if this {@code TimeZone} doesn't * observe Daylight Saving Time). Otherwise, a Standard Time name is * returned. * * <p>When looking up a time zone name, the {@linkplain * ResourceBundle.Control#getCandidateLocales(String,Locale) default * <code>Locale</code> search path of <code>ResourceBundle</code>} derived * from the specified {@code locale} is used. (No {@linkplain * ResourceBundle.Control#getFallbackLocale(String,Locale) fallback * <code>Locale</code>} search is performed.) If a time zone name in any * {@code Locale} of the search path, including {@link Locale#ROOT}, is * found, the name is returned. Otherwise, a string in the * <a href="#NormalizedCustomID">normalized custom ID format</a> is returned. * * @param daylight {@code true} specifying a Daylight Saving Time name, or * {@code false} specifying a Standard Time name * @param style either {@link #LONG} or {@link #SHORT} * @param locale the locale in which to supply the display name. * @return the human-readable name of this time zone in the given locale. * @exception IllegalArgumentException if {@code style} is invalid. * @exception NullPointerException if {@code locale} is {@code null}. * @since 1.2 * @see java.text.DateFormatSymbols#getZoneStrings() */ public String getDisplayName(boolean daylight, int style, Locale locale) { if (style != SHORT && style != LONG) { throw new IllegalArgumentException("Illegal style: " + style); } String id = getID(); String name = TimeZoneNameUtility.retrieveDisplayName(id, daylight, style, locale); if (name != null) { return name; } if (id.startsWith("GMT") && id.length() > 3) { char sign = id.charAt(3); if (sign == '+' || sign == '-') { return id; } } int offset = getRawOffset(); if (daylight) { offset += getDSTSavings(); } return ZoneInfoFile.toCustomID(offset); }
Example 16
Source File: TimeZone.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** * Returns a name in the specified {@code style} of this {@code TimeZone} * suitable for presentation to the user in the specified {@code * locale}. If the specified {@code daylight} is {@code true}, a Daylight * Saving Time name is returned (even if this {@code TimeZone} doesn't * observe Daylight Saving Time). Otherwise, a Standard Time name is * returned. * * <p>When looking up a time zone name, the {@linkplain * ResourceBundle.Control#getCandidateLocales(String,Locale) default * <code>Locale</code> search path of <code>ResourceBundle</code>} derived * from the specified {@code locale} is used. (No {@linkplain * ResourceBundle.Control#getFallbackLocale(String,Locale) fallback * <code>Locale</code>} search is performed.) If a time zone name in any * {@code Locale} of the search path, including {@link Locale#ROOT}, is * found, the name is returned. Otherwise, a string in the * <a href="#NormalizedCustomID">normalized custom ID format</a> is returned. * * @param daylight {@code true} specifying a Daylight Saving Time name, or * {@code false} specifying a Standard Time name * @param style either {@link #LONG} or {@link #SHORT} * @param locale the locale in which to supply the display name. * @return the human-readable name of this time zone in the given locale. * @exception IllegalArgumentException if {@code style} is invalid. * @exception NullPointerException if {@code locale} is {@code null}. * @since 1.2 * @see java.text.DateFormatSymbols#getZoneStrings() */ public String getDisplayName(boolean daylight, int style, Locale locale) { if (style != SHORT && style != LONG) { throw new IllegalArgumentException("Illegal style: " + style); } String id = getID(); String name = TimeZoneNameUtility.retrieveDisplayName(id, daylight, style, locale); if (name != null) { return name; } if (id.startsWith("GMT") && id.length() > 3) { char sign = id.charAt(3); if (sign == '+' || sign == '-') { return id; } } int offset = getRawOffset(); if (daylight) { offset += getDSTSavings(); } return ZoneInfoFile.toCustomID(offset); }
Example 17
Source File: TimeZone.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * Returns a name in the specified {@code style} of this {@code TimeZone} * suitable for presentation to the user in the specified {@code * locale}. If the specified {@code daylight} is {@code true}, a Daylight * Saving Time name is returned (even if this {@code TimeZone} doesn't * observe Daylight Saving Time). Otherwise, a Standard Time name is * returned. * * <p>When looking up a time zone name, the {@linkplain * ResourceBundle.Control#getCandidateLocales(String,Locale) default * <code>Locale</code> search path of <code>ResourceBundle</code>} derived * from the specified {@code locale} is used. (No {@linkplain * ResourceBundle.Control#getFallbackLocale(String,Locale) fallback * <code>Locale</code>} search is performed.) If a time zone name in any * {@code Locale} of the search path, including {@link Locale#ROOT}, is * found, the name is returned. Otherwise, a string in the * <a href="#NormalizedCustomID">normalized custom ID format</a> is returned. * * @param daylight {@code true} specifying a Daylight Saving Time name, or * {@code false} specifying a Standard Time name * @param style either {@link #LONG} or {@link #SHORT} * @param locale the locale in which to supply the display name. * @return the human-readable name of this time zone in the given locale. * @exception IllegalArgumentException if {@code style} is invalid. * @exception NullPointerException if {@code locale} is {@code null}. * @since 1.2 * @see java.text.DateFormatSymbols#getZoneStrings() */ public String getDisplayName(boolean daylight, int style, Locale locale) { if (style != SHORT && style != LONG) { throw new IllegalArgumentException("Illegal style: " + style); } String id = getID(); String name = TimeZoneNameUtility.retrieveDisplayName(id, daylight, style, locale); if (name != null) { return name; } if (id.startsWith("GMT") && id.length() > 3) { char sign = id.charAt(3); if (sign == '+' || sign == '-') { return id; } } int offset = getRawOffset(); if (daylight) { offset += getDSTSavings(); } return ZoneInfoFile.toCustomID(offset); }
Example 18
Source File: TimeZone.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
/** * Returns a name in the specified {@code style} of this {@code TimeZone} * suitable for presentation to the user in the specified {@code * locale}. If the specified {@code daylight} is {@code true}, a Daylight * Saving Time name is returned (even if this {@code TimeZone} doesn't * observe Daylight Saving Time). Otherwise, a Standard Time name is * returned. * * <p>When looking up a time zone name, the {@linkplain * ResourceBundle.Control#getCandidateLocales(String,Locale) default * <code>Locale</code> search path of <code>ResourceBundle</code>} derived * from the specified {@code locale} is used. (No {@linkplain * ResourceBundle.Control#getFallbackLocale(String,Locale) fallback * <code>Locale</code>} search is performed.) If a time zone name in any * {@code Locale} of the search path, including {@link Locale#ROOT}, is * found, the name is returned. Otherwise, a string in the * <a href="#NormalizedCustomID">normalized custom ID format</a> is returned. * * @param daylight {@code true} specifying a Daylight Saving Time name, or * {@code false} specifying a Standard Time name * @param style either {@link #LONG} or {@link #SHORT} * @param locale the locale in which to supply the display name. * @return the human-readable name of this time zone in the given locale. * @exception IllegalArgumentException if {@code style} is invalid. * @exception NullPointerException if {@code locale} is {@code null}. * @since 1.2 * @see java.text.DateFormatSymbols#getZoneStrings() */ public String getDisplayName(boolean daylight, int style, Locale locale) { if (style != SHORT && style != LONG) { throw new IllegalArgumentException("Illegal style: " + style); } String id = getID(); String name = TimeZoneNameUtility.retrieveDisplayName(id, daylight, style, locale); if (name != null) { return name; } if (id.startsWith("GMT") && id.length() > 3) { char sign = id.charAt(3); if (sign == '+' || sign == '-') { return id; } } int offset = getRawOffset(); if (daylight) { offset += getDSTSavings(); } return ZoneInfoFile.toCustomID(offset); }