Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.math.BigInteger;
import java.time.Instant;
import java.util.Date;

public class Main {

    public static void main(String[] args) {
        Instant i = Instant.now();

        System.out.println(toDate(i));

    }

    public static Date toDate(Instant instant) {
        BigInteger milis = BigInteger.valueOf(instant.getEpochSecond()).multiply(BigInteger.valueOf(1000));
        milis = milis.add(BigInteger.valueOf(instant.getNano()).divide(BigInteger.valueOf(1_000_000)));
        return new Date(milis.longValue());
    }
}