datetime format - How to parsing LocalDateTime from RestController in Kotlin -


i'm trying implement controller application using kotlin. there error when parsing datetime format when make request.

@restcontroller @requestmapping("/api/records") class recordcontroller(val recordservice: recordservice) {    @getmapping("details")   fun getrecorddetail(     @requestparam recordid: int,     @requestparam(required = false) @datetimeformat(iso = datetimeformat.iso.date_time) datetime: localdatetime): recorddto {     return recordservice.getrecorddetails(recordid, datetime)   } } 

the error

failed convert value of type 'java.lang.string' required type 'java.time.localdatetime'; nested exception org.springframework.core.convert.conversionfailedexception:  failed convert type [java.lang.string] type [@org.springframework.web.bind.annotation.requestparam @org.springframework.format.annotation.datetimeformat java.time.localdatetime] value '2017-08-21t00:00:000.00'; nested exception java.lang.illegalargumentexception:  parse attempt failed value [2017-08-21t00:00:000.00]" 

the rest api works fine without datetime parameter.

this because provide value format not compatible defined iso-date.

here value (maybe "typo" side) , working value

2017-08-21t00:00:000.00   (yours) 2017-08-21t00:00:00.000   (working) 

ensure provide valid second , millisecond value.


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -