You are here:
Localize Date, Time, and Numbers
Configure locale contracts to show date, time, dateTime, suffix for day and year values, and decimal formats in the language set up in the Consumer Goods mobile app.
Required Editions
| User Permissions Needed | |
|---|---|
| To customize locale contracts: | Customizer, Developer |
Locales determine the date, time, and numeric formats based on the user language setting. You can define the date and time formats by configuring the locale contracts of a user language. Salesforce ships locale contracts for the supported languages in the design contracts package every release.
- Decimal
- Time
- Date
- DateTime
- Download the DesignContracts.<version>.pack zip from Salesforce and extract the zip’s contents. The package contains the DesignContracts_Locales.<version>.signed and DesignContracts.<version>.signed zip files.
- Extract the DesignContracts_Locales.<version>.signed.zip and then open the src/Locale folder.
- Copy the locale contract for your preferred language to the src/Locale folder in your Modeler workspace. For example, de.locale.xml.
-
Add this Localizations code snippet to the locale contract in this specific
order.
<Localizations> <DateFormats> <Date value="MM/DD/YYYY"/> <ShortDate value="MMM ddd"/> <DateTime value="MM/DD/YYYY HH:mm"/> <Time value="HH:mm"/> <CustomDate value="<any_date_format>"/> <PickerDaySuffix value=""/> <PickerYearSuffix value=""/> </DateFormats> <NumberFormats> <DecimalSeparator value="."/> <ThousandSeparator value=","/> </NumberFormats> </Localizations> -
To define the date, time and number format for a locale, configure the Localizations
code snippet.
- Use
CustomDateto define a custom date format on the Welcome card of a cockpit page. If a custom date format isn’t specified, then the date value appears in ddd, MMM D format on the Welcome card. For example, Tue, Jan 17. If you use a long date format inCustomDate, alignment issues may occur on the Welcome card. Developers are responsible for addressing this issue. - To localize the day and year values, define the
PickerDaySuffixandPickerYearSuffixattributes.
- Use
-
Ensure that the nodes within the locale contract adhere to this specific order.
<Locale language="de" languageCode="de"> <Localizations></Localizations> <Translations></Translations> <Images></Images> </Locale> - Save your changes.
Here’s the de.locale contract with the custom date and time format definition.
<Locale language="de" languageCode="de">
<Localizations>
<DateFormats>
<Date value="m/d/Y"/>
<DateTime value="m/d/Y H:i"/>
<Time value="H:i"/>
<CustomDate value="MM/DD"/>
</DateFormats>
<NumberFormats>
<DecimalSeparator value="."/>
<ThousandSeparator value=","/>
</NumberFormats>
</Localizations>
<Translations>
<Framework>
<Label id="Yes" text="Ja" translationStatus="7" />
<Label id="No" text="Nein" translationStatus="7" />
<Label id="Cancel" text="Abbrechen" translationStatus="7" />
....#entries skipped for brevity#
</Framework>
</Translations>
</Locale>In this sample snippet from a Japanese locale, the day and year are suffixed with additional characters. The suffix after the month value comes from the locale.
<Localizations>
<DateFormats>
<Date value="MM月 DD日 YYYY年"/>
<ShortDate value="MM月 DD日"/>
<DateTime value="MM月 DD日 YYYY HH:mm"/>
<Time value="HH:mm"/>
<PickerDaySuffix value="日"/>
<PickerYearSuffix value="年"/>
</DateFormats>
</Localizations>Here are the different date and time format strings supported in the Consumer Goods Cloud offline mobile app.
| Token | Format | |
|---|---|---|
| Month | M | 1 2 ... 11 12 |
| Mo | 1st 2nd ... 11th 12th | |
| MM | 01 02 ... 11 12 | |
| MMM | Jan Feb ... Nov Dec | |
| MMMM | January February ... November December | |
| Quarter | Q | 1 2 3 4 |
| Qo | 1st 2nd 3rd 4th | |
| Day of Month | D | 1 2 ... 30 31 |
| Do | 1st 2nd ... 30th 31st | |
| DD | 01 02 ... 30 31 | |
| Day of Year | DDD | 1 2 ... 364 365 |
| DDDo | 1st 2nd ... 364th 365th | |
| DDDD | 001 002 ... 364 365 | |
| Day of Week (locale) | e | 0 1 ... 5 6 |
| Day of Week (ISO) | E | 1 2 ... 6 7 |
| Week of Year | w | 1 2 ... 52 53 |
| wo | 1st 2nd ... 52nd 53rd | |
| ww | 01 02 ... 52 53 | |
| Week of Year (ISO) | W | 1 2 ... 52 53 |
| Wo | 1st 2nd ... 52nd 53rd | |
| WW | 01 02 ... 52 53 | |
| Year | YY | 70 71 ... 29 30 |
| YYYY | 1970 1971 ... 2029 2030 | |
| Y | 1970 1971 ... 9999 +10000 +10001 This complies with the ISO 8601 standard for dates past the year 9999. |
|
| Week Year | 99 | 70 71 ... 29 30 |
| gggg | 1970 1971 ... 2029 2030 | |
| Week Year (ISO) | GG | 70 71 ... 29 30 |
| GGGG | 1970 1971 ... 2029 2030 | |
| AM/PM | A | AM PM |
| a | am pm | |
| Hour | H | 0 1 ... 22 23 |
| HH | 00 01 ... 22 23 | |
| h | 1 2 ... 11 12 | |
| hh | 01 02 ... 11 12 | |
| k | 1 2 ... 23 24 | |
| kk | 01 02 ... 23 24 | |
| Minute | m | 0 1 ... 58 59 |
| mm | 00 01 ... 58 59 | |
| Second | s | 0 1 ... 58 59 |
| ss | 00 01 ... 58 59 | |
| Fractional Second | S | 0 1 ... 8 9 |
| SS | 00 01 ... 98 99 | |
| SSS | 000 001 ... 998 999 | |
| SSSS ... SSSSSSSSS | 000[0..] 001[0..] ... 998[0..] 999[0..] | |
| Time zone | z or zz | EST CST ... MST PST |
| Z | -07:00 -06:00 ... +06:00 +07:00 | |
| ZZ | -0700 -0600 ... +0600 +0700 | |
| Unix Timestamp | X | 1360013296 |
| Unix Millisecond Timestamp | x | 1360013296123 |

