Spring MVC + Joda Time + @DateTimeFormat

6

Description:

Spring does not convert using @DateTimeFormat , I try to send start both ways below and it returns me a 404 . When I send the object without this field it creates the normal object, but it can not create when I request with the start field.

First try

'@DateTimeFormat(pattern = "HH:mm")
 @Type(type="org.jadira.usertype.dateandtime.joda.PersistentLocalTimeAsString")
 LocalTime start'

Second attempt

'@Type(type="org.jadira.usertype.dateandtime.joda.PersistentLocalTimeAsString")
 @DateTimeFormat(pattern = "MM/dd/yyyy")
 private DateTime start;'

Spring documentation:

'Use @DateTimeFormat to format
java.util.Date, java.util.Calendar, java.util.Long, or Joda Time fields.'
    
asked by anonymous 21.02.2014 / 19:43

1 answer

1

First thing you need to check out is the JodaTime and Spring versions.

In your entity declaration you do not need to declare the @Type annotation, spring has already implemented the @DateTimeFormat annotation with direct JodaTime integration.

    
17.03.2014 / 19:45