Days between dates

“2021-01-01” is, as the error says, a String. It’s not a ZonedDateTime. You can’t just type in a String and have it magically become something else. You have to convert that String into a ZonedDateTime. And then you can get at the seconds and do the math with that.

There are lots of options. See ZonedDateTime (Java SE 11 & JDK 11 ) for the full ZonedDateTime docs.

Try something like this:

var day = LocalDate.parse("2021-01-01").atStartOfDay();
var long dif_days = Duration.between(day, now).toDays();

Sorry, you’re right, I forgot to turn the string into a date!
var long dif_days =(new DateTime(day).millis-now.millis)/86400000
It works, thanks!