0Pricing
Java Academy · Lesson

Period and Date Arithmetic

Add and subtract dates.

Date-Based Amounts

While Duration measures time in hours and seconds, Period measures amounts in years, months, and days. It is the right tool for calendar arithmetic like ages and deadlines.

Adding Days

LocalDate offers plusDays to move forward. Remember the result is a new immutable value.

import java.time.LocalDate;

public class Main {
    public static void main(String[] args) {
        LocalDate start = LocalDate.of(2026, 5, 30);
        System.out.println(start.plusDays(10));
    }
}

All lessons in this course

  1. LocalDate, LocalTime, LocalDateTime
  2. Instant and Duration
  3. Period and Date Arithmetic
  4. Formatting with DateTimeFormatter
← Back to Java Academy