I have a SQL column of the nature
`x_date` DATE default null,
… in InnoDB.
Then my entity class is
@Entity
@Table
public class MyEntity{
//omitted codes
@Column(name="x_date")
private java.util.Date theDate;
//Omitted assessor
}
Now I have a Controller class defined like this
@RestController
@RequestMapping("/data")
public class SomeController{
@Autowired
private TheDao dao;
@GetMapping
public List<MyEntity>getByDate(@RequestParam("date")String date){
//How do I get a java util.Date type from the date param to pass to this method?
return dao.findByTheDate(...){
}
}
How do I generate a Date from a user's input like http://localhost:8080/data?date=2001-07-14?
The jpa repo is
public interface TheDao extends JpaRepository<MyEntity, Integer>{
List<MyEntity>findByTheDate(Date date)
}
}
I've changed all Date types to LocalDate in my classes and interface and the controller class has this declaration
LocalDate loc=LocalDate.parse(date);
return dao.findByTheDate(loc);
But when I made a GET call to http://localhost:8080/data?date=2019-03-29 I got this stacktrace
Parameter value [%2019-03-29%] did not match expected type [java.time.LocalDate n/a)]...