0

it.date is a "Date" type (we retrieve from mysql db) and I am trying to do a comparison of a LocalDate.now and return the value in LocalDate type. However, I couldn't find the right way to do this as I am getting parser errors

private val datePattern = "M/d/yy" 
        
if (LocalDate.parse(it.date.toString(), DateTimeFormatter.ofPattern(datePattern)) > LocalDate.now().minusYears(1)){  
         return LocalDate.parse(it.date.toString(), DateTimeFormatter.ofPattern(datePattern))
}
AAA
  • 87
  • 1
  • 1
  • 13
  • Stop using both `java.sql.Date` and `java.util.Date`. Both legacy classes were supplanted years ago by the modern *java.time* classes, replaced by `java.time.LocalDate` and `java.time.Instant` respectively. JDBC 4.2+ requires all JDBC drivers to support the *java.time* types. – Basil Bourque Sep 02 '23 at 21:18

0 Answers0