ms -> LocalDate object. - Java java.time

Java examples for java.time:LocalDate

Description

ms -> LocalDate object.

Demo Code


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

import java.time.ZoneId;

public class Main {
    public static void main(String[] argv) throws Exception {
        long ms = 2;
        System.out.println(ms2LocalDate(ms));
    }/*  w  w  w.  ja  v a2  s . c  o  m*/

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

Related Tutorials