Java Convert Calendar to Milliseconds
Tags: Java Calendar
In this Java core tutorial we learn how to convert a java.util.Calendar object into milliseconds value.
How to convert Calendar to Milliseconds
In Java we can use the Calendar.getTimeInMillis() method to get the milliseconds value of a Calendar object as following Java code.
ConvertCalendarToMillisecondsExample1.java
import java.util.Calendar;
public class ConvertCalendarToMillisecondsExample1 {
public static void main(String... args) {
Calendar calendar = Calendar.getInstance();
// Convert Calendar to milliseconds
long milliseconds = calendar.getTimeInMillis();
System.out.println(milliseconds);
}
}
1650091071321
Happy Coding 😊
Related Articles
Java Convert Calendar to Instant