Javatpoint Logo
Javatpoint Logo

Convert Milliseconds to Date in Java

In Java, usually we need to convert milliseconds into the Date of different format such as dd MMM yyyy and dd MMM yyyy HH:mm:ss:SSS Z, etc.

The Date is one of the most important class in Java to work with Date. It internally stores the Date in milliseconds. By using the constructor of the Date class, we can create a Date from milliseconds.

Before proceeding further, it is required to gain knowledge of the SimpleDateFormat class. It is one of the classes that we use to format and parse data. It helps us to convert a date from one format into another one. It is also helpful in converting a date of string format into a date object. In simple words, the SimpleDateFormat class is used for modifying Date accordingly.

Let's take some examples to understand how we can convert milliseconds to Date.

MillisecondsToDateExample1.java

Output:

Convert Milliseconds to Date in Java

MillisecondsToDateExample2.java

Output:

Convert Milliseconds to Date in Java





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA