Convert Milliseconds to Date

In this section, you will learn to convert a millisecond into a date.

Convert Milliseconds to Date

In this section, you will learn to convert a millisecond into a date.

Convert Milliseconds to Date

Convert Milliseconds to Date

     

In this section, you will learn to convert a millisecond into a date. 

Description of program:

This program helps you in converting milliseconds into a date. It uses some java methods and APIs.  you need a millisecond that have to be converted. The taken milliseconds is passed in the Date() constructor. It is then passed through the format() method that invokes with SimpleDateFormat() and it provides the given format. 

 The code of the program is given below:

import java.util.*;
import java.text.*;
public class MillisecondToDate {
 public static void main(String[] args)throws Exception {
 long yourmilliseconds = 1119193190;
SimpleDateFormat sdf = new SimpleDateFormat("MMM dd,yyyy HH:mm");
 
Date resultdate = new Date(yourmilliseconds);
System.out.println(sdf.format(resultdate));  
}    

The output of the program is given below:

C:\date>javac MillisecondToDate.java
C:\date>java MillisecondToDate
Jan 14,1970 04:23

Download this example.