We would like to know how to convert Calendar to Instant.
import java.time.Instant; import java.util.Calendar; /*ww w . j a va2s . c o m*/ public class Main { public static void main(String[] args) { // Calendar to Instant Instant time = Calendar.getInstance().toInstant(); System.out.println(time); } }
The code above generates the following result.