0

I am getting the Epoch time data as 1376493600 (String). I want to convert it into Human Readable/Normal Date String (dd-mm-yyyy hh:mm:ss) format

<fmt:parseDate value="${record.attributes.P_Close_Time}" pattern="dd/MM/yyyy HH:mm:ss" var="date" />
<fmt:formatDate value="${date}" pattern="dd/MM/yyyy HH:mm:ss" />

But I am getting Unparsable Date error in the fmt:parseDate line.

How to convert the epoc time to readable date format as mentioned.

RaceBase
  • 18,428
  • 47
  • 141
  • 202

3 Answers3

0

Can't you do this in your controller by converting the string to an integer then load it into a Date object?

date = new Date(Integer.valueOf(timeData)*1000);

Then you can format that Date object however you like.

Tim B
  • 40,716
  • 16
  • 83
  • 128
0

use

Date date = new Date (Long.parase(epochString)); 
SimpleDateFormat sdf = new SimpleDateFormat(String pattern);
String formatted  = sdf.forms(date);
0

try this:

 package naveed.workingfiles;

import java.sql.Timestamp;
import java.util.Date;

public class TimestampToDate {

    /**
     * @param args
     */
    public static void main(String[] args) {
          Timestamp stamp = new Timestamp(Long.parseLong("1376493600"));
          Date date = new Date(stamp.getTime());
          System.out.println(date);

    }

    }
KhAn SaAb
  • 5,248
  • 5
  • 31
  • 52