Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.time.LocalDate;
import java.time.LocalTime;
import java.time.Month;
import java.time.temporal.ChronoUnit;

public class Main {

    public static void main(String[] args) {
        LocalDate ld1 = LocalDate.of(2014, Month.JANUARY, 7);
        LocalDate ld2 = LocalDate.of(2014, Month.MAY, 21);
        long days = ChronoUnit.DAYS.between(ld1, ld2);
        System.out.println(days);

        LocalTime lt1 = LocalTime.of(6, 0);
        LocalTime lt2 = LocalTime.of(9, 30);
        long hours = ChronoUnit.HOURS.between(lt1, lt2);
        System.out.println(hours);
        long minutes = ChronoUnit.MINUTES.between(lt1, lt2);
        System.out.println(minutes);
    }
}