Class Formats.DateFormatter

java.lang.Object
play.data.format.Formatters.SimpleFormatter<Date>
play.data.format.Formats.DateFormatter
Enclosing class:
Formats

public static class Formats.DateFormatter extends Formatters.SimpleFormatter<Date>
Formatter for java.util.Date values.
  • Constructor Details

    • DateFormatter

      public DateFormatter(MessagesApi messagesApi)
      Creates a date formatter. The value defined for the message file key "formats.date" will be used as the default pattern.
      Parameters:
      messagesApi - messages to look up the pattern
    • DateFormatter

      public DateFormatter(MessagesApi messagesApi, String pattern)
      Creates a date formatter.
      Parameters:
      messagesApi - messages to look up the pattern
      pattern - date pattern, as specified for SimpleDateFormat. Can be a message file key.
    • DateFormatter

      public DateFormatter(MessagesApi messagesApi, String pattern, String patternNoApp)
      Creates a date formatter.
      Parameters:
      messagesApi - messages to look up the pattern
      pattern - date pattern, as specified for SimpleDateFormat. Can be a message file key.
      patternNoApp - date pattern to use as fallback when no app is started.
  • Method Details

    • parse

      public Date parse(String text, Locale locale) throws ParseException
      Binds the field - constructs a concrete value from submitted data.
      Specified by:
      parse in class Formatters.SimpleFormatter<Date>
      Parameters:
      text - the field text
      locale - the current Locale
      Returns:
      a new value
      Throws:
      ParseException - if the text could not be parsed into T
    • print

      public String print(Date value, Locale locale)
      Unbinds this fields - converts a concrete value to a plain string.
      Specified by:
      print in class Formatters.SimpleFormatter<Date>
      Parameters:
      value - the value to unbind
      locale - the current Locale
      Returns:
      printable version of the value