Java Reference
In-Depth Information
Format
Example (Varies According to Locale)
DateFormat.SHORT
1 27 07
DateFormat.MEDIUM
Jan 27 2007
DateFormat.LONG
January 27 2007
d MMM yy
27 Jan 07
yyyy M d
2007 01 27
yyyy MMM d
2007 Jan 27
EEE MMM dd HH:mm:ss zzz yyyy
Sat Jan 27 07:27:00 EST 2007
If all formats fail, the converter produces a validation error.
Using Different Date Format Patterns
It's easy to configure the date type converter to use different date format
patterns. For example, we might want to use a pattern that reads the
date and the time. Looking at the default date formats, the only one
that includes the time is EEE MMM dd HH:mm:ss zzz yyyy , which is quite
tedious for the user to type!
To configure a list of date format patterns that will replace the defaults
for the date type converter—and for all date fields of the application—
add a line to the StripesResources.properties file. Using the stripes.dateType-
Converter.formatStrings key, define a comma-separated list of date format
patterns in order of priority. For example:
Use a space to separate
the date parts when
defining a format
pattern.
stripes.dateTypeConverter.formatStrings=yyyy M d HH:mm, yyyy M d
The first pattern parses both the date and the time, while the second
pattern parses just the date. This makes it easy for the user to enter
the date and the time, while also allowing only the date to be entered.
Enumerated Types
Stripes also provides a type converter for working with enumerated
types (types defined with enum ). The converter takes a String input and
produces an enum of type T using Enum.valueOf(T, input) . For this to work,
the input must exactly match the identifier used to declare the enum
constant in the type T .
For example, given an enumerated type:
public enum Gender {
Female,
Male
}
the input would have to be either "Female" or "Male" (case sensitive) to
be converted to the Gender type.
 
 
 
Search WWH ::




Custom Search