Module: ojconverter-preferences

Oracle® JavaScript Extension Toolkit (JET)
17.0.0

F92240-01

QuickNav

JET Modules

See JET Module Loading for an overview of module usage within JET.

Functions

formatWithYearFormat(formatInstance, yearInstance, value) : {string}

Merges in the formatted year.

Parameters:
Name Type Description
formatInstance Intl.DateTimeFormat formatInstance: Intl.DateTimeFormat,
yearInstance Intl.DateTimeFormat yearInstance: Intl.DateTimeFormat
value Date
Returns:
Type
string

getDateTimePreferences : {Readonly<DateTimePreferences>}

Gets the date and time preferences. If setDateTimePreferences was not called previously, this function will return a default. The default is dateStyle.short.year that is based on the theme. The Redwood theme returns 'numeric' for year.

Application code should not need to call this function. JET code calls this function to merge in the datetime preferences with the IntlDateTimeConverter options.

Returns:
Type
Readonly<DateTimePreferences>

getNumberPreferences : {Readonly<NumberPreferences>}

Gets the number preferences.

Application code should not need to call this function. JET code calls this function to merge in the number preferences with the IntlNumberConverter or NumberConverter options.

Returns:
Type
Readonly<NumberPreferences>

setDateTimePreferences(options) : {void}

Sets the date and time preferences. Once set, the object is frozen, so calling this function a second time will do nothing.

If a user has date time preferences, the application code must call setDateTimePreferences before any JET rendering is started, so when an instance of JET's IntlDateTimeConverter is created during rendering, the preferences will be there to be used. Do not call setDateTimePreferences if there are no preferences to set.

Parameters:
Name Type Description
options DateTimePreferences An object containing the DateTimePreferences to set.
Returns:
Type
void
Examples

Using setDateTimePreferences() to set a user's preferred pattern for date and time short formats and timeZone.

setDateTimePreferences(
  {
    dateStyle: {short: {pattern: 'mm/dd/yyyy'}},
    timeStyle: {short: { pattern: 'hh:mm' }},
    timeZone: 'America/Los_Angeles'
  }
);

Using setDateTimePreferences() to set a user's preferred date and time short format with the user's system's local timeZone. Note that if timeZone is not set, the default is the user's system's local timeZone, which is what is usually preferred.

setDateTimePreferences(
  {
    dateStyle: {short: {pattern: 'mm/dd/yyyy'}},
    timeStyle: {short: { pattern: 'hh:mm' }}
  }
);

Using setDateTimePreferences() to set a user's preferred timeZone when it could be different than the user's system's local timezone.

setDateTimePreferences(
  {
    timeZone: 'America/Los_Angeles'
  }
);

setNumberPreferences(options) : {void}

Sets the number preferences. Once set, the object is frozen, so calling this function a second time will do nothing.

If a user has number preferences, the application code must call setNumberPreferences before any JET rendering is started, so when an instance of JET's IntlNumberConverter or NumberConverter is created during rendering, the preferences will be there to be used. Do not call setNumberPreferences if there are no preferences to set.

Parameters:
Name Type Description
options NumberPreferences An object containing the NumberPreferences to set.
Returns:
Type
void
Example

Using setNumberPreferences() to set a user's preferred number separators for decimal and currency.

setNumberPreferences(
  {
    style: {
     currency: {separators: {group: ",", decimal: "."}},
     decimal: {separators: {group: ",", decimal: "."}}
    }
  }
);

Type Definitions

CurrencyStylePreferences

Signature:

{currency: NumberPreferencesSeparators}

DateStylePreferencesPattern

Properties:
Name Type Description
short { pattern: string; year?: never } The type for dateStyle.short.pattern. If dateStyle.short.pattern is set, dateStyle.short.year should never be set.

DateStylePreferencesYear

Properties:
Name Type Description
short { year: 'numeric' | '2-digit'; pattern?: never } The type for short year.

DateTimePreferences

Signature:

(ojconverter-preferences.DateTimePreferencesYear | ojconverter-preferences.DateTimePreferencesPattern) & {timeZone?: string}

DateTimePreferencesPattern

Properties:
Name Type Description
dateStyle DateStylePreferencesPattern The user's preferred pattern when the converter's dateStyle option is 'short'. If you set dateStyle.short.pattern, then you must also set timeStyle.short.pattern.
timeStyle TimeStylePreferencesPattern The user's preferred pattern when the converter's timeStyle option is 'short'. If you set timeStyle.short.pattern, then you must also set dateStyle.short.pattern.

DateTimePreferencesYear

Properties:
Name Type Argument Description
dateStyle Partial<ojconverter-preferences.DateStylePreferencesYear> <optional>
The type for the dateStyle.short.year
timeStyle {short?: { pattern: never }} <optional>
If dateStyle.short.year is set, timeStyle.short should never be set.

DecimalSeparators

Signature:

'.' | ','

DecimalStylePreferences

Signature:

{decimal: NumberPreferencesSeparators}

GroupSeparators

Signature:

" " | "." | "," | "'"

NumberPreferences

Signature:

{style?: Partial<ojconverter-preferences.DecimalStylePreferences> & Partial<ojconverter-preferences.CurrencyStylePreferences>}

NumberPreferencesSeparators

Signature:

{separators: ojconverter-preferences.NumberPreferencesSeparatorsContent;}

NumberPreferencesSeparatorsContent

Signature:

{group: ojconverter-preferences.GroupSeparators; decimal: ojconverter-preferences.DecimalSeparators;}

TimeStylePreferencesPattern

Properties:
Name Type Argument Description
short {pattern: string} <optional>
The type for timeStyle.short.pattern.