Java LocalDate create from millisecond

Description

Java LocalDate create from millisecond

import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;

public class Main {
  public static void main(String[] argv) throws Exception {
    long l = new Date().getTime();
    System.out.println(ms2LocalDate(l));
  }/*from  w  ww. j a v a 2s.  c  o  m*/

  public static LocalDate ms2LocalDate(final long ms) {
    return LocalDateTime.ofInstant(Instant.ofEpochMilli(ms), ZoneId.systemDefault()).toLocalDate();
  }
}



PreviousNext

Related