Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.time.Duration;
import java.time.LocalDate;
import java.time.Period;
import java.time.temporal.ChronoUnit;
import java.time.temporal.UnsupportedTemporalTypeException;

public class Main {

    public static void main(String[] args) {
        LocalDate localDate = LocalDate.of(2012, 11, 23);
        System.out.println(localDate.plus(3, ChronoUnit.DAYS)); //2012-11-26

        System.out.println(localDate.plus(Period.ofDays(3))); //2012-11-26
        try {
            System.out.println(localDate.plus(Duration.ofDays(3)));

            System.out.println(localDate.plus(4, ChronoUnit.FOREVER));
        } catch (UnsupportedTemporalTypeException e) {
            e.printStackTrace();
        }
    }
}