How do I convert a LocalDate to a java.sql.Date
?
Attempt:
Record r = new Record();
LocalDate date = new Date(1967, 06, 22);
r.setDateOfBirth(new Date(date));
This fails (won't compile) and all I can find is Joda time stuff.
I'm using Java 8
converterjavajava-8java-timesqldatetime
How do I convert a LocalDate to a java.sql.Date
?
Attempt:
Record r = new Record();
LocalDate date = new Date(1967, 06, 22);
r.setDateOfBirth(new Date(date));
This fails (won't compile) and all I can find is Joda time stuff.
I'm using Java 8
Best Answer
The answer is really simple;
If you would want to convert it the other way around, you do it like this:
r
is the record you're using in JOOQ and.getDate()
is the method for getting the date out of your record; let's say you have a date column called date_of_birth, then your get method should be calledgetDateOfBirth()
.