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.