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.temporal.ChronoUnit;

public class Main {

    public static void main(String[] args) {
        Duration duration = Duration.ofDays(33); //seconds or nanos

        Duration duration1 = Duration.ofHours(33); //seconds or nanos
        Duration duration2 = Duration.ofMillis(33); //seconds or nanos
        Duration duration3 = Duration.ofMinutes(33); //seconds or nanos
        Duration duration4 = Duration.ofNanos(33); //seconds or nanos
        Duration duration5 = Duration.ofSeconds(33); //seconds or nanos
        Duration duration6 = Duration.between(LocalDate.of(2012, 11, 11), LocalDate.of(2013, 1, 1));

        System.out.println(duration6.getSeconds());
        System.out.println(duration.getNano());
        System.out.println(duration.getSeconds());
    }
}