Ejemplo n.º 1
0
        /// <summary>
        /// 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.
        ///
        /// <para>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 <seealso cref="Locale#ROOT"/>, is
        /// found, the name is returned. Otherwise, a string in the
        /// <a href="#NormalizedCustomID">normalized custom ID format</a> is returned.
        ///
        /// </para>
        /// </summary>
        /// <param name="daylight"> {@code true} specifying a Daylight Saving Time name, or
        ///                 {@code false} specifying a Standard Time name </param>
        /// <param name="style"> either <seealso cref="#LONG"/> or <seealso cref="#SHORT"/> </param>
        /// <param name="locale">   the locale in which to supply the display name. </param>
        /// <returns> the human-readable name of this time zone in the given locale. </returns>
        /// <exception cref="IllegalArgumentException"> if {@code style} is invalid. </exception>
        /// <exception cref="NullPointerException"> if {@code locale} is {@code null}.
        /// @since 1.2 </exception>
        /// <seealso cref= java.text.DateFormatSymbols#getZoneStrings() </seealso>
        public virtual String GetDisplayName(bool daylight, int style, Locale locale)
        {
            if (style != SHORT && style != LONG)
            {
                throw new IllegalArgumentException("Illegal style: " + style);
            }
            String id   = ID;
            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 = RawOffset;

            if (daylight)
            {
                offset += DSTSavings;
            }
            return(ZoneInfoFile.toCustomID(offset));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Write out the default serializable data, after ensuring the
        /// <code>zoneStrings</code> field is initialized in order to make
        /// sure the backward compatibility.
        ///
        /// @since 1.6
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void writeObject(java.io.ObjectOutputStream stream) throws java.io.IOException
        private void WriteObject(ObjectOutputStream stream)
        {
            if (ZoneStrings_Renamed == null)
            {
                ZoneStrings_Renamed = TimeZoneNameUtility.getZoneStrings(Locale);
            }
            stream.DefaultWriteObject();
        }
Ejemplo n.º 3
0
        private String[][] GetZoneStringsImpl(bool needsCopy)
        {
            if (ZoneStrings_Renamed == null)
            {
                ZoneStrings_Renamed = TimeZoneNameUtility.getZoneStrings(Locale);
            }

            if (!needsCopy)
            {
                return(ZoneStrings_Renamed);
            }

            int len = ZoneStrings_Renamed.Length;

            String[][] aCopy = new String[len][];
            for (int i = 0; i < len; i++)
            {
                aCopy[i] = Arrays.CopyOf(ZoneStrings_Renamed[i], ZoneStrings_Renamed[i].Length);
            }
            return(aCopy);
        }
Ejemplo n.º 4
0
 private static String[] GetDisplayNames(String id, Locale locale)
 {
     return(TimeZoneNameUtility.retrieveDisplayNames(id, locale));
 }