Internationalization class provides support to parse and format the number and date object to the desired format.
// To set the culture globally
setCulture('en-GB');
// To set currency code globally
setCurrencyCode('EUR');
//Load cldr data
loadCldr(gregorainData);
loadCldr(timeZoneData);
loadCldr(numbersData);
loadCldr(numberSystemData);
// To use formatter in component side
let Intl:Internationalization = new Internationalization();
// Date formatting
let dateFormatter: Function = Intl.getDateFormat({skeleton:'long',type:'dateTime'});
dateFormatter(new Date('11/2/2016'));
dateFormatter(new Date('25/2/2030'));
Intl.formatDate(new Date(),{skeleton:'E'});
//Number formatting
let numberFormatter: Function = Intl.getNumberFormat({skeleton:'C5'})
numberFormatter(24563334);
Intl.formatNumber(123123,{skeleton:'p2'});
// Date parser
let dateParser: Function = Intl.getDateParser({skeleton:'short',type:'time'});
dateParser('10:30 PM');
Intl.parseDate('10',{skeleton:'H'});
Returns the formatted date string based on format options.
Parameter | Type | Description |
---|---|---|
value | Date |
Specifies the number to format. |
option (optional) | DateFormatOptions |
Specifies the format options in which the number will be formatted. |
Returns string
Returns the formatted string based on format options.
Parameter | Type | Description |
---|---|---|
value | number |
Specifies the number to format. |
option (optional) | NumberFormatOptions |
Specifies the format options in which the number will be formatted. |
Returns string
Returns the format function for given options.
Parameter | Type | Description |
---|---|---|
options (optional) | DateFormatOptions |
Specifies the format options in which the format function will return. |
Returns Function
Returns the parser function for given options.
Parameter | Type | Description |
---|---|---|
options (optional) | DateFormatOptions |
Specifies the format options in which the parser function will return. |
Returns Function
Returns the First Day of the Week
Returns number
Returns the format function for given options.
Parameter | Type | Description |
---|---|---|
options (optional) | NumberFormatOptions |
Specifies the format options in which the format function will return. |
Returns Function
Returns the parser function for given options.
Parameter | Type | Description |
---|---|---|
options (optional) | NumberFormatOptions |
Specifies the format options in which the parser function will return. |
Returns Function
Returns the date object for given date string and options.
Parameter | Type | Description |
---|---|---|
value | string |
Specifies the string to parse. |
option (optional) | DateFormatOptions |
Specifies the parse options in which the date string will be parsed. |
Returns Date
Returns the number object from the given string value and options.
Parameter | Type | Description |
---|---|---|
value | string |
Specifies the string to parse. |
option (optional) | NumberFormatOptions |
Specifies the parse options in which the string number will be parsed. |
Returns number