How can I convert unix time to java?
Get the following:
~#>date -d @1305176400 Thu May 12 00:00:00 CDT 2011
But in java
String date = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss") .format(new java.util.Date (epoch*1000));
See: http://www.epochconverter.com/
Do you mean this?
Date d = new Date(1305176400 * 1000L); System.out.println(d);
prints
Thu May 12 06:00:00 BST 2011
Take a look at the SimpleDateFormat class. The documentation describes how to create the correct format that you can use to convert from date to String and vice versa.
Date date = new Date(msSinceEpoch); //note: input is ms since epoch, not seconds String s = DateFormat.getDateTimeInstance().format(date);
to make sure the formatting matches your default language.