How do you bind a Date to in stripes using a specific format? “MM/dd/yyyy HH:mm:ss”
<s:text name="myDateTime" formatPattern="MM/dd/yyyy HH:mm:ss" />
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Stripes uses Typeconverters for converting request parameters (Strings) to specific types. The javadoc for the default Date type converter can be found here:
net.sourceforge.stripes.validation.DateTypeConverter
To change the default formats it states:
And:
If that does not do it for you, you can always roll you’re own TypeConverter. This custom type converter can then be bound to a setter in the ActionBean by:
If you want to let the mapping be done automatically you either need to override the default mapper or create another (sub) type. For example, you create your own type converter not for java.util.Date but for your own custom type that inherits from java.util.Date. As it’s just a sub type without any extra behavior, the rest of the application can use it as java.util.Date.