< prev index next >

src/java.base/share/classes/java/util/spi/CalendarNameProvider.java

Print this page




  29 import java.util.Locale;
  30 import java.util.Map;
  31 
  32 /**
  33  * An abstract class for service providers that provide localized string
  34  * representations (display names) of {@code Calendar} field values.
  35  *
  36  * <p><a id="calendartypes"><b>Calendar Types</b></a>
  37  *
  38  * <p>Calendar types are used to specify calendar systems for which the {@link
  39  * #getDisplayName(String, int, int, int, Locale) getDisplayName} and {@link
  40  * #getDisplayNames(String, int, int, Locale) getDisplayNames} methods provide
  41  * calendar field value names. See {@link Calendar#getCalendarType()} for details.
  42  *
  43  * <p><b>Calendar Fields</b>
  44  *
  45  * <p>Calendar fields are specified with the constants defined in {@link
  46  * Calendar}. The following are calendar-common fields and their values to be
  47  * supported for each calendar system.
  48  *
  49  *  <table class="plain">
  50  * <caption style="display:none">Field values</caption>
  51  * <thead>
  52  *   <tr>
  53  *     <th>Field</th>
  54  *     <th>Value</th>
  55  *     <th>Description</th>
  56  *   </tr>
  57  * </thead>
  58  * <tbody>
  59  *   <tr>
  60  *     <td style="vertical-align:top">{@link Calendar#MONTH}</td>
  61  *     <td style="vertical-align:top">{@link Calendar#JANUARY} to {@link Calendar#UNDECIMBER}</td>
  62  *     <td>Month numbering is 0-based (e.g., 0 - January, ..., 11 -
  63  *         December). Some calendar systems have 13 months. Month
  64  *         names need to be supported in both the formatting and
  65  *         stand-alone forms if required by the supported locales. If there's
  66  *         no distinction in the two forms, the same names should be returned
  67  *         in both of the forms.</td>
  68  *   </tr>
  69  *   <tr>
  70  *     <td style="vertical-align:top">{@link Calendar#DAY_OF_WEEK}</td>
  71  *     <td style="vertical-align:top">{@link Calendar#SUNDAY} to {@link Calendar#SATURDAY}</td>
  72  *     <td>Day-of-week numbering is 1-based starting from Sunday (i.e., 1 - Sunday,
  73  *         ..., 7 - Saturday).</td>
  74  *   </tr>
  75  *   <tr>
  76  *     <td style="vertical-align:top">{@link Calendar#AM_PM}</td>
  77  *     <td style="vertical-align:top">{@link Calendar#AM} to {@link Calendar#PM}</td>
  78  *     <td>0 - AM, 1 - PM</td>
  79  *   </tr>
  80  * </tbody>
  81  * </table>
  82  *
  83  * <p style="margin-top:20px">The following are calendar-specific fields and their values to be supported.
  84  *
  85  * <table class="plain">
  86  * <caption style="display:none">Calendar type and field values</caption>
  87  * <thead>
  88  *   <tr>
  89  *     <th>Calendar Type</th>
  90  *     <th>Field</th>
  91  *     <th>Value</th>
  92  *     <th>Description</th>
  93  *   </tr>
  94  * </thead>
  95  * <tbody>
  96  *   <tr>
  97  *     <td rowspan="2" style="vertical-align:top">{@code "gregory"}</td>
  98  *     <td rowspan="2" style="vertical-align:top">{@link Calendar#ERA}</td>
  99  *     <td>0</td>
 100  *     <td>{@link java.util.GregorianCalendar#BC} (BCE)</td>
 101  *   </tr>
 102  *   <tr>
 103  *     <td>1</td>
 104  *     <td>{@link java.util.GregorianCalendar#AD} (CE)</td>
 105  *   </tr>
 106  *   <tr>
 107  *     <td rowspan="2" style="vertical-align:top">{@code "buddhist"}</td>
 108  *     <td rowspan="2" style="vertical-align:top">{@link Calendar#ERA}</td>
 109  *     <td>0</td>
 110  *     <td>BC (BCE)</td>
 111  *   </tr>
 112  *   <tr>
 113  *     <td>1</td>
 114  *     <td>B.E. (Buddhist Era)</td>
 115  *   </tr>
 116  *   <tr>
 117  *     <td rowspan="6" style="vertical-align:top">{@code "japanese"}</td>
 118  *     <td rowspan="5" style="vertical-align:top">{@link Calendar#ERA}</td>
 119  *     <td>0</td>
 120  *     <td>Seireki (Before Meiji)</td>
 121  *   </tr>
 122  *   <tr>
 123  *     <td>1</td>
 124  *     <td>Meiji</td>
 125  *   </tr>
 126  *   <tr>
 127  *     <td>2</td>
 128  *     <td>Taisho</td>
 129  *   </tr>
 130  *   <tr>
 131  *     <td>3</td>
 132  *     <td>Showa</td>
 133  *   </tr>
 134  *   <tr>
 135  *     <td>4</td>
 136  *     <td >Heisei</td>
 137  *   </tr>
 138  *   <tr>
 139  *     <td>{@link Calendar#YEAR}</td>
 140  *     <td>1</td>
 141  *     <td>the first year in each era. It should be returned when a long
 142  *     style ({@link Calendar#LONG_FORMAT} or {@link Calendar#LONG_STANDALONE}) is
 143  *     specified. See also the <a href="../../text/SimpleDateFormat.html#year">
 144  *     Year representation in {@code SimpleDateFormat}</a>.</td>
 145  *   </tr>
 146  *   <tr>
 147  *     <td rowspan="2" style="vertical-align:top">{@code "roc"}</td>
 148  *     <td rowspan="2" style="vertical-align:top">{@link Calendar#ERA}</td>
 149  *     <td>0</td>
 150  *     <td>Before R.O.C.</td>
 151  *   </tr>
 152  *   <tr>
 153  *     <td>1</td>
 154  *     <td>R.O.C.</td>
 155  *   </tr>
 156  *   <tr>
 157  *     <td rowspan="2" style="vertical-align:top">{@code "islamic"}</td>
 158  *     <td rowspan="2" style="vertical-align:top">{@link Calendar#ERA}</td>
 159  *     <td>0</td>
 160  *     <td>Before AH</td>
 161  *   </tr>
 162  *   <tr>
 163  *     <td>1</td>
 164  *     <td>Anno Hijrah (AH)</td>
 165  *   </tr>
 166  * </tbody>
 167  * </table>
 168  *
 169  * <p>Calendar field value names for {@code "gregory"} must be consistent with
 170  * the date-time symbols provided by {@link java.text.spi.DateFormatSymbolsProvider}.
 171  *
 172  * <p>Time zone names are supported by {@link TimeZoneNameProvider}.
 173  *
 174  * @author Masayoshi Okutsu
 175  * @since 1.8
 176  * @see CalendarDataProvider
 177  * @see Locale#getUnicodeLocaleType(String)
 178  */
 179 public abstract class CalendarNameProvider extends LocaleServiceProvider {
 180     /**
 181      * Sole constructor. (For invocation by subclass constructors, typically
 182      * implicit.)
 183      */




  29 import java.util.Locale;
  30 import java.util.Map;
  31 
  32 /**
  33  * An abstract class for service providers that provide localized string
  34  * representations (display names) of {@code Calendar} field values.
  35  *
  36  * <p><a id="calendartypes"><b>Calendar Types</b></a>
  37  *
  38  * <p>Calendar types are used to specify calendar systems for which the {@link
  39  * #getDisplayName(String, int, int, int, Locale) getDisplayName} and {@link
  40  * #getDisplayNames(String, int, int, Locale) getDisplayNames} methods provide
  41  * calendar field value names. See {@link Calendar#getCalendarType()} for details.
  42  *
  43  * <p><b>Calendar Fields</b>
  44  *
  45  * <p>Calendar fields are specified with the constants defined in {@link
  46  * Calendar}. The following are calendar-common fields and their values to be
  47  * supported for each calendar system.
  48  *
  49  * <table class="striped">
  50  * <caption style="display:none">Field values</caption>
  51  * <thead>
  52  *   <tr>
  53  *     <th scope="col">Field</th>
  54  *     <th scope="col">Value</th>
  55  *     <th scope="col">Description</th>
  56  *   </tr>
  57  * </thead>
  58  * <tbody>
  59  *   <tr>
  60  *     <th scope="row" style="vertical-align:top">{@link Calendar#MONTH}</th>
  61  *     <td style="vertical-align:top">{@link Calendar#JANUARY} to {@link Calendar#UNDECIMBER}</td>
  62  *     <td>Month numbering is 0-based (e.g., 0 - January, ..., 11 -
  63  *         December). Some calendar systems have 13 months. Month
  64  *         names need to be supported in both the formatting and
  65  *         stand-alone forms if required by the supported locales. If there's
  66  *         no distinction in the two forms, the same names should be returned
  67  *         in both of the forms.</td>
  68  *   </tr>
  69  *   <tr>
  70  *     <th scope="row" style="vertical-align:top">{@link Calendar#DAY_OF_WEEK}</th>
  71  *     <td style="vertical-align:top">{@link Calendar#SUNDAY} to {@link Calendar#SATURDAY}</td>
  72  *     <td>Day-of-week numbering is 1-based starting from Sunday (i.e., 1 - Sunday,
  73  *         ..., 7 - Saturday).</td>
  74  *   </tr>
  75  *   <tr>
  76  *     <th scope="row" style="vertical-align:top">{@link Calendar#AM_PM}</th>
  77  *     <td style="vertical-align:top">{@link Calendar#AM} to {@link Calendar#PM}</td>
  78  *     <td>0 - AM, 1 - PM</td>
  79  *   </tr>
  80  * </tbody>
  81  * </table>
  82  *
  83  * <p style="margin-top:20px">The following are calendar-specific fields and their values to be supported.
  84  *
  85  * <table class="plain">
  86  * <caption style="display:none">Calendar type and field values</caption>
  87  * <thead>
  88  *   <tr>
  89  *     <th scope="col">Calendar Type</th>
  90  *     <th scope="col">Field</th>
  91  *     <th scope="col">Value</th>
  92  *     <th scope="col">Description</th>
  93  *   </tr>
  94  * </thead>
  95  * <tbody>
  96  *   <tr>
  97  *     <th scope="row"rowspan="2" style="font-weight:normal; text-align:left; vertical-align:top">{@code "gregory"}</th>
  98  *     <th scope="row" rowspan="2" style="font-weight:normal; text-align:left; vertical-align:top">{@link Calendar#ERA}</th>
  99  *     <th scope="row" style="font-weight:normal">0</th>
 100  *     <td>{@link java.util.GregorianCalendar#BC} (BCE)</td>
 101  *   </tr>
 102  *   <tr>
 103  *     <th scope="row" style="font-weight:normal">1</th>
 104  *     <td>{@link java.util.GregorianCalendar#AD} (CE)</td>
 105  *   </tr>
 106  *   <tr>
 107  *     <th scope="row" rowspan="2" style="font-weight:normal; text-align:left; vertical-align:top">{@code "buddhist"}</th>
 108  *     <th scope="row" rowspan="2" style="font-weight:normal; text-align:left; vertical-align:top">{@link Calendar#ERA}</th>
 109  *     <th scope="row" style="font-weight:normal">0</th>
 110  *     <td>BC (BCE)</td>
 111  *   </tr>
 112  *   <tr>
 113  *     <th scope="row" style="font-weight:normal">1</th>
 114  *     <td>B.E. (Buddhist Era)</td>
 115  *   </tr>
 116  *   <tr>
 117  *     <th scope="row" rowspan="6" style="font-weight:normal; text-align:left; vertical-align:top">{@code "japanese"}</th>
 118  *     <th scope="row" rowspan="5" style="font-weight:normal; text-align:left; vertical-align:top">{@link Calendar#ERA}</th>
 119  *     <th scope="row" style="font-weight:normal">0</th>
 120  *     <td>Seireki (Before Meiji)</td>
 121  *   </tr>
 122  *   <tr>
 123  *     <th scope="row" style="font-weight:normal">1</th>
 124  *     <td>Meiji</td>
 125  *   </tr>
 126  *   <tr>
 127  *     <th scope="row" style="font-weight:normal">2</th>
 128  *     <td>Taisho</td>
 129  *   </tr>
 130  *   <tr>
 131  *     <th scope="row" style="font-weight:normal">3</th>
 132  *     <td>Showa</td>
 133  *   </tr>
 134  *   <tr>
 135  *     <th scope="row" style="font-weight:normal">4</th>
 136  *     <td >Heisei</td>
 137  *   </tr>
 138  *   <tr>
 139  *     <th scope="row" style="font-weight:normal; text-align:left; vertical-align:top">{@link Calendar#YEAR}</th>
 140  *     <th scope="row" style="font-weight:normal">1</th>
 141  *     <td>the first year in each era. It should be returned when a long
 142  *     style ({@link Calendar#LONG_FORMAT} or {@link Calendar#LONG_STANDALONE}) is
 143  *     specified. See also the <a href="../../text/SimpleDateFormat.html#year">
 144  *     Year representation in {@code SimpleDateFormat}</a>.</td>
 145  *   </tr>
 146  *   <tr>
 147  *     <th scope="row" rowspan="2" style="font-weight:normal; text-align:left; vertical-align:top">{@code "roc"}</th>
 148  *     <th scope="row" rowspan="2" style="font-weight:normal; text-align:left; vertical-align:top">{@link Calendar#ERA}</th>
 149  *     <th scope="row" style="font-weight:normal">0</th>
 150  *     <td>Before R.O.C.</td>
 151  *   </tr>
 152  *   <tr>
 153  *     <th scope="row" style="font-weight:normal">1</th>
 154  *     <td>R.O.C.</td>
 155  *   </tr>
 156  *   <tr>
 157  *     <th scope="row" rowspan="2" style="font-weight:normal; text-align:left; vertical-align:top">{@code "islamic"}</th>
 158  *     <th scope="row" rowspan="2" style="font-weight:normal; text-align:left; vertical-align:top">{@link Calendar#ERA}</th>
 159  *     <th scope="row" style="font-weight:normal">0</th>
 160  *     <td>Before AH</td>
 161  *   </tr>
 162  *   <tr>
 163  *     <th scope="row" style="font-weight:normal">1</th>
 164  *     <td>Anno Hijrah (AH)</td>
 165  *   </tr>
 166  * </tbody>
 167  * </table>
 168  *
 169  * <p>Calendar field value names for {@code "gregory"} must be consistent with
 170  * the date-time symbols provided by {@link java.text.spi.DateFormatSymbolsProvider}.
 171  *
 172  * <p>Time zone names are supported by {@link TimeZoneNameProvider}.
 173  *
 174  * @author Masayoshi Okutsu
 175  * @since 1.8
 176  * @see CalendarDataProvider
 177  * @see Locale#getUnicodeLocaleType(String)
 178  */
 179 public abstract class CalendarNameProvider extends LocaleServiceProvider {
 180     /**
 181      * Sole constructor. (For invocation by subclass constructors, typically
 182      * implicit.)
 183      */


< prev index next >