user3480820
user3480820

Reputation: 63

Import failing for java.time.LocalDate

import java.time.LocalDate;
import java.time.Period;

    public class DateDiff {

        public static void main(String[] args) {
            /** The date at the end of the last century */
            LocalDate endofCentury = LocalDate.of(2000, 12, 31);
            LocalDate now = LocalDate.now();

            Period diff = Period.between(endofCentury, now);

            System.out.printf("The 21st century (up to %s) is %s old%n", now, diff);
            System.out.printf("The 21st century is %d years, %d months and %d days old",
                    diff.getYears(), diff.getMonths(), diff.getDays());
        }
    }

Local Date is not being found am I missing an import directive

Upvotes: 1

Views: 6951

Answers (1)

peter.petrov
peter.petrov

Reputation: 39477

Check if you're using JDK 8.
I guess you're not and that's your issue.

Upvotes: 9

Related Questions