Kotlin Date to LocalDate comparison

21 Views Asked by At

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))
}
0

There are 0 best solutions below