Class DateFormatter<V>

java.lang.Object
io.jmix.ui.component.formatter.DateFormatter<V>
All Implemented Interfaces:
Formatter<V>, Function<V,String>

@Component("ui_DateFormatter") @Scope("prototype") public class DateFormatter<V> extends Object implements Formatter<V>
Date formatter to be used in screen descriptors and controllers.

This formatter formats the Date value into a string depending on the format string.

  • Field Details

    • currentAuthentication

      @Autowired protected CurrentAuthentication currentAuthentication
    • formatStringsRegistry

      @Autowired protected FormatStringsRegistry formatStringsRegistry
    • dateTimeTransformations

      @Autowired protected DateTimeTransformations dateTimeTransformations
    • format

      protected String format
    • type

      protected String type
    • useUserTimezone

      protected boolean useUserTimezone
  • Constructor Details

    • DateFormatter

      public DateFormatter()
  • Method Details

    • setFormat

      @StudioProperty(type=LOCALIZED_STRING) public void setFormat(String format)
      Sets the format string describing the date format which will be used to create SimpleDateFormat instance. It can be either a format string, or a key in message group.
      Parameters:
      format - a format string or a key in message group
    • setType

      @StudioProperty(type=ENUMERATION, options={"DATE","DATETIME"}) public void setType(String type)
      Sets the formatter type, which can have a DATE or DATETIME value. If specified, the value will be formatted by means of DateDatatype or DateTimeDatatype respectively.
      Parameters:
      type - a formatter type
    • setUseUserTimezone

      @StudioProperty(defaultValue="false") public void setUseUserTimezone(boolean useUserTimezone)
      Sets whether formatter should display the date and time in the current user's timezone.
      Parameters:
      useUserTimezone - true if the formatter displays the date and time in the current user's timezone, false otherwise
    • apply

      @Nullable public String apply(@Nullable V value)
      Description copied from interface: Formatter
      Formats a value to a string.
      Specified by:
      apply in interface Formatter<V>
      Specified by:
      apply in interface Function<V,String>
      Parameters:
      value - a value
      Returns:
      formatted string
    • applyFormatInternal

      protected String applyFormatInternal(V value)