public SerialDateUtilities() { base.\u002Ector(); SerialDateUtilities serialDateUtilities = this; this.dateFormatSymbols = new DateFormatSymbols(); this.weekdays = this.dateFormatSymbols.getWeekdays(); this.months = this.dateFormatSymbols.getMonths(); }
/// <summary> /// Returns a DateFormatSymbols provided by a provider or found in /// the cache. Note that this method returns a cached instance, /// not its clone. Therefore, the instance should never be given to /// an application. /// </summary> internal static DateFormatSymbols GetInstanceRef(Locale locale) { DateFormatSymbols dfs = GetProviderInstance(locale); if (dfs != null) { return(dfs); } throw new RuntimeException("DateFormatSymbols instance creation failed."); }
/// <summary> /// Overrides Cloneable /// </summary> public virtual Object Clone() { try { DateFormatSymbols other = (DateFormatSymbols)base.Clone(); CopyMembers(this, other); return(other); } catch (CloneNotSupportedException e) { throw new InternalError(e); } }
private static DateFormatSymbols GetProviderInstance(Locale locale) { LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(typeof(DateFormatSymbolsProvider), locale); DateFormatSymbolsProvider provider = adapter.DateFormatSymbolsProvider; DateFormatSymbols dfsyms = provider.GetInstance(locale); if (dfsyms == null) { provider = LocaleProviderAdapter.forJRE().DateFormatSymbolsProvider; dfsyms = provider.GetInstance(locale); } return(dfsyms); }
/// <summary> /// Override equals /// </summary> public override bool Equals(Object obj) { if (this == obj) { return(true); } if (obj == null || this.GetType() != obj.GetType()) { return(false); } DateFormatSymbols that = (DateFormatSymbols)obj; return(Arrays.Equals(Eras_Renamed, that.Eras_Renamed) && Arrays.Equals(Months_Renamed, that.Months_Renamed) && Arrays.Equals(ShortMonths_Renamed, that.ShortMonths_Renamed) && Arrays.Equals(Weekdays_Renamed, that.Weekdays_Renamed) && Arrays.Equals(ShortWeekdays_Renamed, that.ShortWeekdays_Renamed) && Arrays.Equals(Ampms, that.Ampms) && Arrays.DeepEquals(ZoneStringsWrapper, that.ZoneStringsWrapper) && ((LocalPatternChars_Renamed != null && LocalPatternChars_Renamed.Equals(that.LocalPatternChars_Renamed)) || (LocalPatternChars_Renamed == null && that.LocalPatternChars_Renamed == null))); }
/// <summary> /// Clones all the data members from the source DateFormatSymbols to /// the target DateFormatSymbols. This is only for subclasses. </summary> /// <param name="src"> the source DateFormatSymbols. </param> /// <param name="dst"> the target DateFormatSymbols. </param> private void CopyMembers(DateFormatSymbols src, DateFormatSymbols dst) { dst.Eras_Renamed = Arrays.CopyOf(src.Eras_Renamed, src.Eras_Renamed.Length); dst.Months_Renamed = Arrays.CopyOf(src.Months_Renamed, src.Months_Renamed.Length); dst.ShortMonths_Renamed = Arrays.CopyOf(src.ShortMonths_Renamed, src.ShortMonths_Renamed.Length); dst.Weekdays_Renamed = Arrays.CopyOf(src.Weekdays_Renamed, src.Weekdays_Renamed.Length); dst.ShortWeekdays_Renamed = Arrays.CopyOf(src.ShortWeekdays_Renamed, src.ShortWeekdays_Renamed.Length); dst.Ampms = Arrays.CopyOf(src.Ampms, src.Ampms.Length); if (src.ZoneStrings_Renamed != null) { dst.ZoneStrings_Renamed = src.GetZoneStringsImpl(true); } else { dst.ZoneStrings_Renamed = null; } dst.LocalPatternChars_Renamed = src.LocalPatternChars_Renamed; dst.CachedHashCode = 0; }
private JPanel getCalendarPanel() { JPanel.__\u003Cclinit\u003E(); JPanel jpanel1 = new JPanel((LayoutManager) new GridLayout(7, 7)); string[] shortWeekdays = new DateFormatSymbols().getShortWeekdays(); for (int index = 0; index < this.WEEK_DAYS.Length; ++index) { JPanel jpanel2 = jpanel1; JLabel.__\u003Cclinit\u003E(); JLabel jlabel = new JLabel(shortWeekdays[this.WEEK_DAYS[index]], 0); ((Container) jpanel2).add((Component) jlabel); } this.buttons = new JButton[42]; for (int index = 0; index < 42; ++index) { JButton jbutton = new JButton(""); ((AbstractButton) jbutton).setMargin(new Insets(1, 1, 1, 1)); ((Component) jbutton).setName(Integer.toString(index)); ((JComponent) jbutton).setFont(this.dateFont); ((AbstractButton) jbutton).setFocusPainted(false); ((AbstractButton) jbutton).setActionCommand("dateButtonClicked"); ((AbstractButton) jbutton).addActionListener((ActionListener) this); this.buttons[index] = jbutton; ((Container) jpanel1).add((Component) jbutton); } return jpanel1; }
public MonthDateFormat(TimeZone zone, Locale locale, int chars, bool[] showYear, DateFormat yearFormatter) { base.\u002Ector(); MonthDateFormat monthDateFormat = this; if (locale == null) { string str = "Null 'locale' argument."; Throwable.__\u003CsuppressFillInStackTrace\u003E(); throw new IllegalArgumentException(str); } else { string[] months = new DateFormatSymbols(locale).getMonths(); this.months = new string[12]; for (int index = 0; index < 12; ++index) this.months[index] = chars <= 0 ? months[index] : String.instancehelper_substring(months[index], 0, Math.min(chars, String.instancehelper_length(months[index]))); this.calendar = (__Null) new GregorianCalendar(zone); this.showYear = showYear; this.yearFormatter = yearFormatter; this.numberFormat = (__Null) NumberFormat.getNumberInstance(); } }
private void InitializeData(Locale desiredLocale) { Locale = desiredLocale; // Copy values of a cached instance if any. SoftReference <DateFormatSymbols> @ref = CachedInstances[Locale]; DateFormatSymbols dfs; if (@ref != null && (dfs = @ref.get()) != null) { CopyMembers(dfs, this); return; } // Initialize the fields from the ResourceBundle for locale. LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(typeof(DateFormatSymbolsProvider), Locale); // Avoid any potential recursions if (!(adapter is ResourceBundleBasedAdapter)) { adapter = LocaleProviderAdapter.ResourceBundleBased; } ResourceBundle resource = ((ResourceBundleBasedAdapter)adapter).LocaleData.getDateFormatData(Locale); // JRE and CLDR use different keys // JRE: Eras, short.Eras and narrow.Eras // CLDR: long.Eras, Eras and narrow.Eras if (resource.ContainsKey("Eras")) { Eras_Renamed = resource.GetStringArray("Eras"); } else if (resource.ContainsKey("long.Eras")) { Eras_Renamed = resource.GetStringArray("long.Eras"); } else if (resource.ContainsKey("short.Eras")) { Eras_Renamed = resource.GetStringArray("short.Eras"); } Months_Renamed = resource.GetStringArray("MonthNames"); ShortMonths_Renamed = resource.GetStringArray("MonthAbbreviations"); Ampms = resource.GetStringArray("AmPmMarkers"); LocalPatternChars_Renamed = resource.GetString("DateTimePatternChars"); // Day of week names are stored in a 1-based array. Weekdays_Renamed = ToOneBasedArray(resource.GetStringArray("DayNames")); ShortWeekdays_Renamed = ToOneBasedArray(resource.GetStringArray("DayAbbreviations")); // Put a clone in the cache @ref = new SoftReference <>((DateFormatSymbols)this.Clone()); SoftReference <DateFormatSymbols> x = CachedInstances.PutIfAbsent(Locale, @ref); if (x != null) { DateFormatSymbols y = x.get(); if (y == null) { // Replace the empty SoftReference with ref. CachedInstances[Locale] = @ref; } } }