Interface DateTimeFormatOptions
@JsType(isNative=true,
namespace="<global>")
public interface DateTimeFormatOptions
Mapping for date
time format options passed to
DateTimeFormat constructors.
In addition to the actual mappings, this class implements the builder pattern using enums to create the options easily and in
a type-safe manner. Some enums are shared with other format option builders of the Intl module and may contain
more values than intended for the given method. In that case the allowed values are listed on the method. In all other cases
all enum values are applicable.
var date = new JsDate(2012, 11, 17, 4, 0, 42);
console.log(dateTimeFormat("en-GB", dateTimeFormatOptions()
.hour(numeric)
.hourCycle(h12)
.dayPeriod(short_)
.timeZone("UTC")).format(date));
// 4 at night" (same formatting in en-GB for all dayPeriod values)
console.log(dateTimeFormat("fr", dateTimeFormatOptions()
.hour(numeric)
.hourCycle(h12)
.dayPeriod(narrow)
.timeZone("UTC")).format(date));
// "4 mat." (same output in French for both narrow/short dayPeriod)
console.log(dateTimeFormat("fr", dateTimeFormatOptions()
.hour(numeric)
.hourCycle(h12)
.dayPeriod(long_)
.timeZone("UTC")).format(date));
// "4 du matin"
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault DateTimeFormatOptionsThe calendar to use, such as "chinese", "gregory", "persian", and so on.default DateTimeFormatOptionsstatic DateTimeFormatOptionsdefault DateTimeFormatOptionsAllowed values:Format.numeric,Format._2digit.default DateTimeFormatOptionsdefault DateTimeFormatOptionsdefault DateTimeFormatOptionsformatMatcher(Matcher formatMatcher) Allowed values:Matcher.basic,Matcher.bestFit.default DateTimeFormatOptionsfractionalSecondDigits(int fractionalSecondDigits) default DateTimeFormatOptionsAllowed values:Format.numeric,Format._2digit.default DateTimeFormatOptionshour12(boolean hour12) default DateTimeFormatOptionsdefault DateTimeFormatOptionslocaleMatcher(Matcher localeMatcher) Allowed values:Matcher.lookup,Matcher.bestFit.default DateTimeFormatOptionsAllowed values:Format.numeric,Format._2digit.default DateTimeFormatOptionsdefault DateTimeFormatOptionsnumberingSystem(String numberingSystem) The numbering system to use for number formatting, such as "arab", "hans", "mathsans", and so on.default DateTimeFormatOptionsAllowed values:Format.numeric,Format._2digit.voidsetCalendar(String calendar) voidsetDateStyle(String dateStyle) voidvoidsetDayPeriod(String dayPeriod) voidvoidsetFormatMatcher(String formatMatcher) voidsetFractionalSecondDigits(int fractionalSecondDigits) voidvoidsetHour12(boolean hour12) voidsetHourCycle(String hourCycle) voidsetLocaleMatcher(String localeMatcher) voidvoidvoidsetNumberingSystem(String numberingSystem) voidvoidsetTimeStyle(String timeStyle) voidsetTimeZone(String timeZone) voidsetTimeZoneName(String timeZoneName) voidsetWeekday(String weekday) voiddefault DateTimeFormatOptionsdefault DateTimeFormatOptionsThe time zone to use.default DateTimeFormatOptionstimeZoneName(TimeZoneName timeZoneName) default DateTimeFormatOptionsdefault DateTimeFormatOptionsAllowed values:Format.numeric,Format._2digit.
-
Method Details
-
dateTimeFormatOptions
-
setCalendar
-
setDateStyle
-
setDay
-
setDayPeriod
-
setEra
-
setFormatMatcher
-
setFractionalSecondDigits
@JsProperty void setFractionalSecondDigits(int fractionalSecondDigits) -
setHour
-
setHour12
@JsProperty void setHour12(boolean hour12) -
setHourCycle
-
setLocaleMatcher
-
setMinute
-
setMonth
-
setNumberingSystem
-
setSecond
-
setTimeStyle
-
setTimeZone
-
setTimeZoneName
-
setWeekday
-
setYear
-
calendar
The calendar to use, such as "chinese", "gregory", "persian", and so on. For a list of supported calendar types, seeIntl.supportedValuesOf(Category). -
dateStyle
-
day
Allowed values:Format.numeric,Format._2digit. -
dayPeriod
-
era
-
formatMatcher
Allowed values:Matcher.basic,Matcher.bestFit. -
fractionalSecondDigits
-
hour
Allowed values:Format.numeric,Format._2digit. -
hour12
-
hourCycle
-
localeMatcher
Allowed values:Matcher.lookup,Matcher.bestFit. -
minute
Allowed values:Format.numeric,Format._2digit. -
month
-
numberingSystem
The numbering system to use for number formatting, such as "arab", "hans", "mathsans", and so on. For a list of supported numbering system types, seeIntl.supportedValuesOf(Category). -
second
Allowed values:Format.numeric,Format._2digit. -
timeStyle
-
timeZone
The time zone to use. Can be any IANA time zone name, including named identifiers such as "UTC", "America/New_York", and "Etc/GMT+8", and offset identifiers such as "+01:00", "-2359", and "+23". The default is the runtime's time zone. -
timeZoneName
-
weekday
-
year
Allowed values:Format.numeric,Format._2digit.
-