src/share/classes/javax/swing/JSpinner.java
Print this page
rev 5615 : 6336885: RFE: Locale Data Deployment Enhancements
4609153: Provide locale data for Indic locales
5104387: Support for gl_ES locale (galician language)
6337471: desktop/system locale preferences support
7056139: (cal) SPI support for locale-dependent Calendar parameters
7058206: Provide CalendarData SPI for week params and display field value names
7073852: Support multiple scripts for digits and decimal symbols per locale
7079560: [Fmt-Da] Context dependent month names support in SimpleDateFormat
7171324: getAvailableLocales() of locale sensitive services should return the actual availability of locales
7151414: (cal) Support calendar type identification
7168528: LocaleServiceProvider needs to be aware of Locale extensions
7171372: (cal) locale's default Calendar should be created if unknown calendar is specified
Summary: JEP 127: Improve Locale Data Packaging and Adopt Unicode CLDR Data (part 1 w/o Jigsaw. by Naoto Sato and Masayoshi Okutsu)
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -34,14 +34,17 @@
import java.util.*;
import java.beans.*;
import java.text.*;
import java.io.*;
-import java.util.HashMap;
-import sun.util.resources.LocaleData;
+import java.text.spi.DateFormatProvider;
+import java.text.spi.NumberFormatProvider;
import javax.accessibility.*;
+import sun.util.locale.provider.LocaleProviderAdapter;
+import sun.util.locale.provider.LocaleResources;
+import sun.util.locale.provider.LocaleServiceProviderPool;
/**
* A single line input field that lets the user select a
* number or an object value from an ordered sequence. Spinners typically
@@ -944,16 +947,17 @@
public static class DateEditor extends DefaultEditor
{
// This is here until SimpleDateFormat gets a constructor that
// takes a Locale: 4923525
private static String getDefaultPattern(Locale loc) {
- ResourceBundle r = LocaleData.getDateFormatData(loc);
- String[] dateTimePatterns = r.getStringArray("DateTimePatterns");
- Object[] dateTimeArgs = {dateTimePatterns[DateFormat.SHORT],
- dateTimePatterns[DateFormat.SHORT + 4]};
- return MessageFormat.format(dateTimePatterns[8], dateTimeArgs);
+ LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, loc);
+ LocaleResources lr = adapter.getLocaleResources(loc);
+ if (lr == null) {
+ lr = LocaleProviderAdapter.forJRE().getLocaleResources(loc);
}
+ return lr.getDateTimePattern(DateFormat.SHORT, DateFormat.SHORT, null);
+ }
/**
* Construct a <code>JSpinner</code> editor that supports displaying
* and editing the value of a <code>SpinnerDateModel</code>
* with a <code>JFormattedTextField</code>. <code>This</code>
@@ -1123,12 +1127,18 @@
{
// This is here until DecimalFormat gets a constructor that
// takes a Locale: 4923525
private static String getDefaultPattern(Locale locale) {
// Get the pattern for the default locale.
- ResourceBundle rb = LocaleData.getNumberFormatData(locale);
- String[] all = rb.getStringArray("NumberPatterns");
+ LocaleProviderAdapter adapter;
+ adapter = LocaleProviderAdapter.getAdapter(NumberFormatProvider.class,
+ locale);
+ LocaleResources lr = adapter.getLocaleResources(locale);
+ if (lr == null) {
+ lr = LocaleProviderAdapter.forJRE().getLocaleResources(locale);
+ }
+ String[] all = lr.getNumberPatterns();
return all[0];
}
/**
* Construct a <code>JSpinner</code> editor that supports displaying