How to convert LocalDate to SQL Date Java?

后端 未结 3 1338
我寻月下人不归
我寻月下人不归 2020-11-28 06:44

How do I convert a LocalDate to a java.sql.Date?

Attempt:

Record r = new Record();
LocalDate date = new Date(1967, 06, 22);
r.setDateOfB         


        
3条回答
  •  星月不相逢
    2020-11-28 06:53

    Have you tried using the toDate() method of LocalDate?

    As in:

    Record r = new Record();
    LocalDate date = new Date(1967, 06, 22);
    r.setDateOfBirth(date.toDate());
    

    In general, it is a good idea to specify how it fails rather than just say "it fails".

提交回复
热议问题