Java Date create from Instant

Introduction

To create Date object from Instant object, call from() on Date class.

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

public class Main {
  public static void main(String[] args) {
    Instant in = Instant.now(); 
    System.out.println("Instant: "  + in);

    Date  dt2  = Date.from(in); 
    System.out.println("Date: "  + dt2);
  }/*from   w  ww  .  j  av  a2  s .c  o m*/
}



PreviousNext

Related