I need a function to find the difference(in number of days)between two dates in "yyyy-mm-dd" format.
val basedate = "1970-01-01"
val currdate = "2015-02-25"
val diff = currdate - basedate
Please suggest.
I need a function to find the difference(in number of days)between two dates in "yyyy-mm-dd" format.
val basedate = "1970-01-01"
val currdate = "2015-02-25"
val diff = currdate - basedate
Please suggest.
i think You are searching something like this
import java.time.LocalDate
import java.time.format.DateTimeFormatter
val startDate = "1970-01-01"
val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd")
val oldDate = LocalDate.parse(startDate, formatter)
val currentDate = "2015-02-25"
val newDate = LocalDate.parse(currentDate, formatter)
println(newDate.toEpochDay() - oldDate.toEpochDay())