ms -> ZonedDateTime object. - Java java.time

Java examples for java.time:ZonedDateTime

Description

ms -> ZonedDateTime object.

Demo Code


//package com.java2s;
import java.time.Instant;

import java.time.ZoneId;

import java.time.ZonedDateTime;

public class Main {
    public static void main(String[] argv) throws Exception {
        long ms = 2;
        System.out.println(ms2ZonedDateTime(ms));
    }/*from  w ww.  j  a va 2 s  .  c  o  m*/

    /**
     * ms -> ZonedDateTime object.
     * @param ms millisecond
     * @return LocalDateTime
     */
    public static ZonedDateTime ms2ZonedDateTime(final long ms) {
        return ZonedDateTime.ofInstant(Instant.ofEpochMilli(ms),
                ZoneId.systemDefault());
    }
}

Related Tutorials