Configure the Date Formatting Pattern for Date Fields
Overview
This page explains how to configure the date formatting pattern for Date and CalendarDate fields in Bloomreach Content document types.
Default Behavior
By default, the format of a Date or CalendarDate field in a document type depends on the UI language selected by the user at login. For example:
- English:
M/d/yyyy - French:
d-M-yyyy
You can override this default and apply a fixed, language-independent date pattern. You can configure the pattern globally for all fields of a type, or for an individual field in a specific document type.
For pattern syntax, refer to the org.joda.time.format.DateTimeFormatter javadoc.
Note: The steps below apply to Date fields. To configure CalendarDate fields, replace
/hippo:namespaces/system/Datewith/hippo:namespaces/system/CalendarDate.
Make the Date Pattern Configurable
- In the Console, navigate to
/hippo:namespaces/system/Date/editor:templates/_default_. - Add
date.patternto the existing multi-value String propertyfrontend:properties:
/hippo:namespaces/system/Date/editor:templates/_default_: frontend:properties: [mode, date.pattern]
- Navigate to
/hippo:namespaces/system/Date/editor:templates/_default_/root. - Add a String property
date.patternto thedatepickernode, and set its value to${date.pattern}:
/hippo:namespaces/system/Date/editor:templates/_default_/root: /datepicker: jcr:primaryType: frontend:pluginconfig date.pattern: ${date.pattern}
- Save your changes to the repository.
After completing these steps, you can configure the date pattern for all Date fields or for a specific Date field in a document type.
Configure the Date Pattern for All Date Fields
- Ensure you have completed the steps in Make the Date Pattern Configurable.
- In the Console, go to
/hippo:namespaces/system/Date/editor:templates/_default_. - Add a String property
date.patternwith the desired pattern, for example:
/hippo:namespaces/system/Date/editor:templates/_default_: date.pattern: yyyy-MM-dd
- Save your changes to the repository.
All Date fields in all document types will now use the configured pattern, regardless of the UI language.
Configure the Date Pattern for a Specific Date Field in a Document Type
The following example uses a project created from the Bloomreach Content Maven archetype, named myproject, with the News feature added. The News feature provides a document type News Item (myproject:newsdocument) with a Date field at path date.
- Ensure you have completed the steps in Make the Date Pattern Configurable.
- In the Console, navigate to
/hippo:namespaces/myproject/newsdocument/editor:templates/_default_/date/cluster.options. - Add a String property
date.patternwith the desired pattern, for example:
/hippo:namespaces/myproject/newsdocument/editor:templates/_default_/date/cluster.options: date.pattern: yyyy-MM-dd
- Save your changes to the repository.
The Date field in the News Item document type will now use the specified pattern, regardless of the UI language.
Pattern Precedence
If you configure a date pattern both globally (for all Date fields) and for a specific Date field, the pattern set on the specific field takes precedence.