I know I can bind a Spring MVC form bean to a LocalDateTime using:
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
private LocalDateTime startTime;
This will convert a String like 2016-01-11T15:05:05.123Z
to a LocalDateTime
object.
I have found some docs on this here: http://blog.codeleak.pl/2014/06/spring-4-datetimeformat-with-java-8.html
I could not find how to do the same with java.time.Duration
. How do I do this?
Form Handling Support in Spring MVC Model: basically a POJO (Plain Old Java Object) class is created to bind form fields with properties of the object. This object will be put into the model (model object).
General information. The spring:bind tag provides you with support for evaluation of the status of a certain bean or bean property.
It seems nothing is needed. It works out of the box (Using Spring Boot 1.3.1 with Spring 4.2.4) with Duration and ZoneId:
private Duration duration;
private ZoneId timeZone;
I tested with "PT15H" string for duration and "Europe/Brussels" for timeZone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With