Can't get time field from input, constantly getting error message:
Field error in object 'recipe' on field 'prepTime': rejected value [04:00]; codes [typeMismatch.recipe.prepTime,typeMismatch.prepTime,typeMismatch.java.sql.Time,typeMismatch];
arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [recipe.prepTime,prepTime]; arguments []; default message [prepTime]]; default message [Failed to convert property value of type [java.lang.String] to required type [java.sql.Time] for property 'prepTime'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [@org.springframework.format.annotation.DateTimeFormat java.sql.Time] for value '04:00'; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.util.Date] to type [@org.springframework.format.annotation.DateTimeFormat java.sql.Time]]
My POJO class:
@Entity
public class Recipe {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Lob
private byte[] photo;
@Size (min=3, max=100, message = "size of field Name must be between 3 and 100")
private String name;
private String description;
@ManyToOne
private Category category;
@DateTimeFormat(pattern = "mm:ss")
private Time prepTime;
@DateTimeFormat(pattern = "mm:ss")
private Time cookTime;
private String addedFlag;
and input field in form html:
<input type="time" th:placeholder="${recipe.prepTime}" th:field="${recipe.prepTime}"/>
So, what I'm doing wrong?