Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

public class Main {

    public static void main(String[] args) {
        Period employmentPeriod = period(LocalDate.of(2000, Month.FEBRUARY, 1));
        int years = employmentPeriod.getYears();
        int months = employmentPeriod.getMonths();
        int days = employmentPeriod.getDays();

        System.out.println(years);
        System.out.println(months);
        System.out.println(days);
    }

    public static Period period(LocalDate hiringDate) {
        LocalDate today = LocalDate.now();
        return Period.between(hiringDate, today);
    }

}