Creates a new Formatter instance
The locale to use for formatting operations
The locale for the formatter Used for all formatting operations
Format a numeric value for a given style
The numeric value to format (string, number, or bigint)
Optionaloptions: NumberFormatOptions
Optional formatting options (style, currency, etc.)
Formatted number string according to the current locale
Format a numeric value to a currency
The numeric value to format as currency
Currency formatting options including currency code
Formatted currency string
Format value as a date. The method accepts the following data types:
The date value to format
Optionaloptions: DateTimeFormatOptions
Optional date formatting options
Formatted date string according to the current locale
Format value as time. The method accepts the following data types:
The time value to format
Optionaloptions: TimeFormatOptions
Optional time formatting options
Formatted time string according to the current locale
Format value as relative diff between the current time and the given value. The following data types are allowed:
The date/time value to format relatively
The unit for relative formatting or 'auto' for automatic unit selection
Optionaloptions: RelativeTimeFormatOptions
Optional relative time formatting options
Formatted relative time string
Format the value to its plural counterpart using locale-specific plural rules
The numeric value to determine plural form for
Optionaloptions: PluralRulesOptions
Optional plural rules options
Plural category string ("zero", "one", "two", "few", "many", or "other")
Format an array of strings to a sentence using locale-appropriate conjunctions
Iterable of strings to format into a list
Optionaloptions: ListFormatOptions
Optional list formatting options (type, style)
Formatted list string
Format region, currency, language codes to their display names
The code to get display name for (language, region, currency, etc.)
Display names options specifying the type of code
Localized display name for the code
Core formatter to format different values using the I18n API. Provides methods for formatting numbers, currencies, dates, times, relative time, plurals, lists, and display names.
Example