Java Calendar convert to Instant

Description

Java Calendar convert to Instant

import java.time.Instant;
import java.util.Calendar;

public class Main {
  public static void main(String[] args) {
     Calendar cal = Calendar.getInstance();
     System.out.println("cal:"+cal);
     //from w w w .ja v  a2 s .c o  m
     Instant ins = cal.toInstant();
     
     System.out.println("Ins:"+ins);

  }
}



PreviousNext

Related