Class sap.ca.ui.model.format.DateFormatModule: sap/ca/ui/model/format/DateFormat
The DateFormat is a static class for formatting and parsing date and time values according to a set of format options.
It uses sap.ui.core.format.DateFormat to format and parse dates, and adds a new style daysAgo for Date instances. With this style:
- For today: "Today" will be displayed (localized)
- For yesterday: "1 day ago" will be displayed (localized)
- Between 2 days and 6 days in the past: "x days ago" will be displayed (localized)
- In the future or more than 6 days in the past: the date will be formatted with a medium style
Supported format options are pattern based on Unicode LDML Date Format notation. If no pattern is specified a default pattern according to the locale settings is used.
Deprecated API:Deprecated API:Since version 1.28. This control has been made available in sap.ui.core. Please use sap.ui.core.format.DateFormat instead! This control will not be supported anymore.
Constructor Summary
new sap.ca.ui.model.format.DateFormat()Constructor for DateFormat - must not be used: To get a DateFormat instance, please use getInstance, getDateTimeInstance or getTimeInstance.
Method Summary
sap.ca.ui.model.format.DateFormat.getDateInstance(oFormatOptions?, oLocale?)Get a date instance of the DateFormat, which can be used for formatting.
sap.ca.ui.model.format.DateFormat.getDateTimeInstance(oFormatOptions?, oLocale?)Get a datetime instance of the DateFormat, which can be used for formatting.
sap.ca.ui.model.format.DateFormat.getTimeInstance(oFormatOptions?, oLocale?)Get a time instance of the DateFormat, which can be used for formatting.
Constructor Detail
new sap.ca.ui.model.format.DateFormat()
Constructor for DateFormat - must not be used: To get a DateFormat instance, please use getInstance, getDateTimeInstance or getTimeInstance.
- Deprecated:
- Deprecated API:Since version 1.28. This control has been made available in sap.ui.core. Please use sap.ui.core.format.DateFormat instead! This control will not be supported anymore.
Method Detail
sap.ca.ui.model.format.DateFormat.getDateInstance(oFormatOptions?, oLocale?): sap.ca.ui.model.format.DateFormat
Get a date instance of the DateFormat, which can be used for formatting.
Parameters:
{object} | oFormatOptions? | Object which defines the format options |
{string} | oFormatOptions.pattern? | a data pattern in LDML format. It is not verified whether the pattern represents only a date. |
{string} | oFormatOptions.style? | either empty or 'short, 'medium', 'long' or 'daysAgo'. If no pattern is given, a locale dependent default date pattern of that style is used from the LocaleData class. |
{sap.ui.core.Locale} | oLocale? | Locale to ask for locale specific texts/settings |
Returns:
{sap.ca.ui.model.format.DateFormat} | date instance of the DateFormat |
sap.ca.ui.model.format.DateFormat.getDateTimeInstance(oFormatOptions?, oLocale?): sap.ca.ui.model.format.DateFormat
Get a datetime instance of the DateFormat, which can be used for formatting.
Parameters:
{object} | oFormatOptions? | Object which defines the format options |
{string} | oFormatOptions.pattern? | a datetime pattern in LDML format. It is not verified whether the pattern represents a full datetime. |
{string} | oFormatOptions.style? | either empty or 'short, 'medium' or 'long'. If no pattern is given, a locale dependent default datetime pattern of that style is used from the LocaleData class. |
{sap.ui.core.Locale} | oLocale? | Locale to ask for locale specific texts/settings |
Returns:
{sap.ca.ui.model.format.DateFormat} | datetime instance of the DateFormat |
sap.ca.ui.model.format.DateFormat.getTimeInstance(oFormatOptions?, oLocale?): sap.ca.ui.model.format.DateFormat
Get a time instance of the DateFormat, which can be used for formatting.
Parameters:
{object} | oFormatOptions? | Object which defines the format options |
{string} | oFormatOptions.pattern? | a time pattern in LDML format. It is not verified whether the pattern only represents a time. |
{string} | oFormatOptions.style? | either empty or 'short, 'medium' or 'long'. If no pattern is given, a locale dependent default time pattern of that style is used from the LocaleData class. |
{sap.ui.core.Locale} | oLocale? | Locale to ask for locale specific texts/settings |
Returns:
{sap.ca.ui.model.format.DateFormat} | time instance of the DateFormat |
format(oValue, bUTC): string
Format a date according to the given format options.
If oValue contains a JSON date ("/Date(milliseconds)/"), it will be converted to a Date before to be formatted.
Parameters:
{Date|string} | oValue | the vale to format |
{boolean} | bUTC | whether to use UTC |
Returns:
{string} | the formatted output value |