java - DateTimeFormat ISO & Spring MVC -
i have controller i'm trying test using mockmvc
@requestmapping(value = "/something/{language}", method = requestmethod.get, produces = { "application/json", "application/xml" }) public responseentity<someentity> getinfo( @pathvariable string language, @datetimeformat(iso= datetimeformat.iso.date_time) @requestparam(required = false) date fromdate )
so i'm expecting allow date formats in docs parsable: date_time common iso datetime format yyyy-mm-dd't'hh:mm:ss.sssz, e.g.
however keep on getting things this:
handler execution resulted in exception: failed convert value of type 'java.lang.string' required type 'java.util.date'; nested exception is
org.springframework.core.convert.conversionfailedexception: failed conv ert type java.lang.string type @org.springframework.format.annotation.datetimeformat @org.springframework.web.bind.annotation.requestparam java.util.date value '2015-09-26t01:30:00.000z'; nested exception java.lang.illegalargumentexception: unable parse '2015-09-26t01:30:00.000z'
as far can see i'm not doing wrong, must of course. can shine light bad is? don't think need post more code since exception show correct value i'm passing api right?
as per datetimeformat.iso.date_time
the common iso datetime format yyyy-mm-dd't'hh:mm:ss.sssz, e.g. 2000-10-31 01:30:00.000-05:00.
where z
represents timezone value example -05:00.
your string value unparseable 2015-09-26t01:30:00.000z
z must replaced actual timezone value.
for example 2015-09-26t01:30:00.000-04:00
parsed iso.date_time
correctly
Comments
Post a Comment