View Single Post
  #1 (permalink)  
Old 12-13-2007, 06:05 PM
amyedwards amyedwards is offline
Member
 
Join Date: Dec 2007
Location: Massachusetts, USA
Posts: 3
amyedwards is on a distinguished road
Converting Epoch to string Date
Hello all:

I'm new here and though I'm not "new" to Java per se, I don't use it on a daily basis and I find that I need a little help with a conversion.

I have an attribute on an object (LAST_MODIFIED) whose value is a date in epoch format (e.g., 1197560243, which is Dec 13, 2007). I'm doing a little conversion based on some posts I read here, to get it into a readable format. That code looks like this:

private String convertDate( Long str )
{
Date epoch = new Date(str);
DateFormat df2 = DateFormat.getDateInstance(DateFormat.MEDIUM);
String s2 = df2.format(epoch);

return s2;

}

The value of the converted date, however, always ends up being "Jan 14, 1970", which (obviously) isn't correct. Can anyone tell me where I'm going wrong? Any assistance is greatly appreciated!!

Kind regards,
Amy. (who is exceedingly frustrated)
Reply With Quote
Sponsored Links