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/Date with /hippo:namespaces/system/CalendarDate.

Make the Date Pattern Configurable

  1. In the Console, navigate to /hippo:namespaces/system/Date/editor:templates/_default_.
  2. Add date.pattern to the existing multi-value String property frontend:properties:
/hippo:namespaces/system/Date/editor:templates/_default_: frontend:properties: [mode, date.pattern]
  1. Navigate to /hippo:namespaces/system/Date/editor:templates/_default_/root.
  2. Add a String property date.pattern to the datepicker node, and set its value to ${date.pattern}:
/hippo:namespaces/system/Date/editor:templates/_default_/root: /datepicker: jcr:primaryType: frontend:pluginconfig date.pattern: ${date.pattern}
  1. 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

  1. Ensure you have completed the steps in Make the Date Pattern Configurable.
  2. In the Console, go to /hippo:namespaces/system/Date/editor:templates/_default_.
  3. Add a String property date.pattern with the desired pattern, for example:
/hippo:namespaces/system/Date/editor:templates/_default_: date.pattern: yyyy-MM-dd
  1. 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.

  1. Ensure you have completed the steps in Make the Date Pattern Configurable.
  2. In the Console, navigate to /hippo:namespaces/myproject/newsdocument/editor:templates/_default_/date/cluster.options.
  3. Add a String property date.pattern with the desired pattern, for example:
/hippo:namespaces/myproject/newsdocument/editor:templates/_default_/date/cluster.options: date.pattern: yyyy-MM-dd
  1. 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.

Share Feedback
Page: /build/document-types/document-types/configure-date-formatting-pattern-for-date-fields
Section: Build
Category *
Configure the Date Formatting Pattern for Date Fields | Bloomreach Content Documentation