Hello guys,
I want to calculate difference between two days. I have seen enough things in internet, but nothing helped me…
def currentDate = new Date()
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd")
SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd")
try {
Date datee = format.parse(currentDate)
Date datee2 = format.parse(model.nextInstallmentDate)
println ("distance is: " + differentDaysByMillisecond(datee, datee2))
}
catch (Exception e) {
println e
}
public int differentDaysByMillisecond(Date datee, Date datee2) {
return (int)((datee2.getTime()-datee.getTime()) /1000/60/60/24)
}
I’ve seen this code on stackoverflow, but it does not work.