Package play.data.format
Class Formats.DateFormatter
- 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 forjava.util.Date
values.
-
-
Constructor Summary
Constructors Constructor Description DateFormatter(MessagesApi messagesApi)
Creates a date formatter.DateFormatter(MessagesApi messagesApi, String pattern)
Creates a date formatter.DateFormatter(MessagesApi messagesApi, String pattern, String patternNoApp)
Creates a date formatter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Date
parse(String text, Locale locale)
Binds the field - constructs a concrete value from submitted data.String
print(Date value, Locale locale)
Unbinds this fields - converts a concrete value to a plain string.
-
-
-
Constructor Detail
-
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 patternpattern
- date pattern, as specified forSimpleDateFormat
. 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 patternpattern
- date pattern, as specified forSimpleDateFormat
. Can be a message file key.patternNoApp
- date pattern to use as fallback when no app is started.
-
-
Method Detail
-
parse
public Date parse(String text, Locale locale) throws ParseException
Binds the field - constructs a concrete value from submitted data.- Specified by:
parse
in classFormatters.SimpleFormatter<Date>
- Parameters:
text
- the field textlocale
- the currentLocale
- Returns:
- a new value
- Throws:
ParseException
- if the text could not be parsed into T
-
-