I'm trying to use this jquery input mask plugin to submit a date time field.
The input is being submitted as:
081220151530
- which is 3:30pm 08/12/2015
or in am/pm it's submitting
081220150330p
I'm trying to bind that value to a Joda DateTime field and I think I should be able to specify a custom pattern on the field annotation.
But this pattern's not matching and throwing a validation fault:
@org.springframework.format.annotation.DateTimeFormat(pattern = "DDMMYYYYhhmm")
private DateTime followUp;
The error:
Failed to convert property value of type 'java.lang.String' to required type 'org.joda.time.DateTime' for property 'followUp'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type java.lang.String to type @javax.persistence.Basic @org.hibernate.annotations.Type @org.springframework.format.annotation.DateTimeFormat org.joda.time.DateTime for value '081220151230'; nested exception is org.joda.time.IllegalFieldValueException: Cannot parse "081220151230": Value 22 for monthOfYear must be in the range [1,12]
So 2 questions: 1. Ideally, it could parse the am/pm value, so is there a pattern that will match the am/pm style?
- If not, what's the right pattern string to match the 24 hour version?
Update to original question:
So I figured out the 24H pattern, using the DateFormat pattern ddMMyyyyHHmm
But the second part I can't get - so I'm going to reassign this to the jquery-inputmask
tag because the fact that it's submitting the am/pm as a
and p
respectively maybe a bug....
So I think I can solve this if someone knows how to make it submit pm/am instead?