I'm trying to get all data of a user of a user with a timestamp:
@GetMapping("/datum/{userID}/{timeStamp}")
List<Datum> getDataSingleUserTimeRange(@PathVariable Long userID, @PathVariable LocalDateTime timeStamp)
{
....
}
Now to test this Spring Boot rest api, in postman, I made this call GET
and url - http://localhost:8080/datum/2/2019-12-15T19:37:15.330995
.
But it gives me error saying : Failed to convert value of type 'java.lang.String' to required type 'java.time.LocalDateTime'
How can I resolve this ??
You need @DateTimeFormat with custom pattern that matches to your input
I don't know if it is the most modest way to do this or not, but here is what I have done :
Passed as string and parsed that. And
dateTime.truncatedTo(ChronoUnit.NECESARRY_UNIT);
can be used as well.