8176706: Additional Date-Time Formats

Reviewed-by: joehw, rriggs
This commit is contained in:
Naoto Sato 2022-02-16 16:54:53 +00:00
parent 0f3d3ac32c
commit 9b74c3f2e7
12 changed files with 809 additions and 96 deletions

View file

@ -27,6 +27,7 @@
package sun.text.spi;
import java.time.DateTimeException;
import java.util.Locale;
import java.util.spi.LocaleServiceProvider;
@ -41,10 +42,10 @@ public abstract class JavaTimeDateTimePatternProvider extends LocaleServiceProvi
}
/**
* Gets the formatting pattern for a timeStyle
* Returns the formatting pattern for a timeStyle
* dateStyle, calendarType and locale.
* Concrete implementation of this method will retrieve
* a java.time specific dateTime Pattern from selected Locale Provider.
* a java.time specific dateTime Pattern from the selected Locale Provider.
*
* @param timeStyle an {@code int} value, representing FormatStyle constant, -1
* for date-only pattern
@ -58,4 +59,26 @@ public abstract class JavaTimeDateTimePatternProvider extends LocaleServiceProvi
* @since 9
*/
public abstract String getJavaTimeDateTimePattern(int timeStyle, int dateStyle, String calType, Locale locale);
/**
* Returns the formatting pattern for the requested template, calendarType, and locale.
* Concrete implementation of this method will retrieve
* a java.time specific pattern from selected Locale Provider.
*
* @param requestedTemplate the requested template, not null
* @param calType a {@code String}, non-null representing CalendarType such as "japanese",
* "iso8601"
* @param locale {@code locale}, non-null
* @throws IllegalArgumentException if {@code requestedTemplate} does not match
* the regular expression syntax described in
* {@link java.time.format.DateTimeFormatterBuilder#appendLocalized(String)}.
* @throws DateTimeException if a match for the formatting pattern for
* {@code requestedTemplate} is not available
* @return formatting pattern {@code String}
* @since 19
*/
public String getJavaTimeDateTimePattern(String requestedTemplate, String calType, Locale locale) {
// default implementation throws exception
throw new DateTimeException("Formatting pattern is not available for the requested template: " + requestedTemplate);
}
}