Java Instant convert to Date

Introduction

To convert Instant to Date value, 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);
  }/*w w  w.  j av a2 s  .com*/
}



PreviousNext

Related