Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

public class Main {

    public static void main(String[] args) {
        LocalTime localTime = LocalTime.of(11, 20, 50);
        System.out.println(localTime.plus(3, ChronoUnit.HOURS));
        System.out.println(localTime.plus(Duration.ofDays(3))); //11:20:50
        try {
            System.out.println(localTime.plus(Period.ofDays(3)));
        } catch (UnsupportedTemporalTypeException e) {
            e.printStackTrace();
        }

    }
}