Share on Google+Share on Google+

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. 

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);

The output of the program is given below:

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

Download this example. 



Posted on: June 16, 2007 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Discuss: Convert Milliseconds to Date   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image