Updated: August 9, 2023

Formatting Dates

sap.ui.core.format.DateFormat

Intro

This article describes the international rules for date formats. The SAPUI5 date formatters will help you to comply with these rules.

Usage

Use date formatting if:

  • You need to display dates based on the user’s locale settings.
  • The application is used in an international context.

Types

You can use five different types of date formats: short, mediumlongfull, and relative. The formatting and order of the values differ based on the locale settings that have been configured in the browser.

Information
The absolute date formats shown below are based on the Unicode Common Locale Data Repository (CLDR). Note that when the SAP Fiori app is running on an ABAP web application server, the “short” and “medium” CLDR patterns are replaced by the patterns defined for the user in the ABAP system.

Short Format

Dates in the short format are displayed as digits for the day, month, and year. Use the correct formatting to avoid errors.

English (US): 8/17/23

Spanish (ES): 17/8/23

Chinese (CN): 23/8/17

German (DE): 17.08.23

Medium Format

In general, you should opt to use the medium date format, which usually shows an abbreviation of the month as text.

English (US): Aug 17, 2023

Spanish (ES): 17 de ago. de 2023

Chinese (CN): 2023年8月17日

German (DE): 17.08.2023

Long Format

Use the long format if you need to display the full names of months. For some languages there may be no difference between the medium and long formats.

English (US): August 17, 2023

Spanish (ES): 17 de agosto de 2023

Chinese (CN): 2023年8月17日

German (DE): 17. August 2023

Full Format

If you need to display the day of the week, use the full date format.

English (US): Thursday, August 17, 2023

Spanish (ES): jueves, 17 de agosto de 2023

Chinese (CN): 2023年8月17日星期四

German (DE): Donnerstag, 17. August 2023

Relative Format

If it suits your use case, such as ongoing events within a period of six days, use the relative format. Relative dates are displayed as text, for example, today, 6 days, and so on.

The default range for relative dates is between -6 and 6 days relative to the current date.

English (US): 2 days ago, yesterday, today, tomorrow, in 2 days

Spanish (ES): hace dos días, ayer, hoy, mañana, dentro de 2 días

Chinese (CN): 2 天前,昨天,今天,明天,2 天后

German (DE): vor 2 Tagen, gestern, heute, morgen, in 2 Tagen

Guidelines

  • In general, use the medium date format.
  • Use the date picker control if dates have to be entered in an input field.

Object List Item and Object Header

Object list item and object header attributes should be formatted with the long type. If space is at a premium, for example, if attributes consist of a label and a date, use the short date format.

Resources

Want to dive deeper? Follow the links below to find out more about related controls, the SAPUI5 implementation, and the visual design.

Elements and Controls

Implementation