Hey, I am trying to use a variable in the entrystart but I cant figure it out how…
I have this:
Entry entry = new Entry();
entry.setTitle(“Whole day”);
Long calculate = ChronoUnit.DAYS.between(vanaf.getValue(),tem.getValue());
I would like to set the “setStart” to start from the vanaf.getValue() and thats a LocalDate type.
I tried like this but It doesnt work.
entry.setStart(Instant.from(vanaf.getValue()));
entry.setEnd(entry.getStart().plusDays(calculate));
Entry provides methods to set start and end as LocalDateTime
(which are then internally converted to Instant
).
If you have a LocalDate
, you need to convert it to LocalDateTime
first before passing it to setStart(LocalDateTime)
, e.g. by using LocalDate#atStartOfDay()
.
Wit the latest version you can now set LocalDate directly.