Search code examples
javadatetimezonedatetime-formatepoch

Time conversion in java


How can I convert unix time in java ?

Get this :

~#>date -d @1305176400
Thu May 12 00:00:00 CDT 2011

But in java


Solution

  • String date = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss")
                      .format(new java.util.Date (epoch*1000));
    

    See: http://www.epochconverter.com/