Operations on dates and times
suggest changeLocalDate tomorrow = LocalDate.now().plusDays(1);
LocalDateTime anHourFromNow = LocalDateTime.now().plusHours(1);
long daysBetween = java.time.temporal.ChronoUnit.DAYS.between(LocalDate.now(), LocalDate.now().plusDays(3)); // 3 unless the two now() calls fall on different dates
Duration duration = Duration.between(Instant.now(), ZonedDateTime.parse("2016-07-27T07:00:00+01:00[Europe/Stockholm]"));
// Stockholm was UTC+2 on that date. Java keeps the instant and resolves this to 08:00+02:00.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents