I have a class file where the date field has value like “1329242400”. This value in UI is represented as “0 day 00:02:56”.
I tried below but I get date in 1970’s.
String attr = "1329242400";
Date cDate = new Date(Long.parseLong(attr));
Output is “Fri Jan 16 04:16:55 EST 1970”
Tried below,
GregorianCalendar c = new GregorianCalendar();
c.setTime(cDate);
XMLGregorianCalendar dDt = DatatypeFactory.newInstance().newXMLGregorianCalendar(c);
Output is “1970-01-16T04:16:55.200-05:00”
What other conversion method should I do to get “0 day 00:02:56” or like “Tue Feb 14 00:02:56 EST 2011”?
The constructor expects the time stamp to be in milliseconds, so you’re off by 3 orders of magnitude: