0

I'm doing this app and I'm having some very weird issues on the Date that I can only assume it's a bug. Currently the UI is only a test mode to see if I'm getting the right data from the servers. For debugging I included this line in the adapter getView I'm using on my list view

    Log.d(DEBUG_TAG, "date: " + item.date.toString() + "; long: " + item.date.getTime());

As I said, that's only testing the data and I don't care about the formatting, the UI is not important, later on I'll be using DateFormater or SimpleDateFormarter.

But at the moment this line is giving me Logs like this:

  date: Fri Jan 16 15:30:14 GMT 1970; long: 1348214602

and if you throw that long on http://www.epochconverter.com/ you'll see the correct value that is some time around today (September 2012), but why is that .toString() giving me January 1970 ???

Has anyone seen that?

edit:

the date object is being created as:

    new Date(miliSeconds)

I've already checked during the instantiation time and the value is the same returned by getTime()

Budius
  • 39,391
  • 16
  • 102
  • 144

2 Answers2

2

Multiply your date by 1000. Somehow you are using seconds instead of miliseconds.

Yellos
  • 1,657
  • 18
  • 33
  • Now that you explained seems so obvious. Actually the data is coming from here http://developers.facebook.com/docs/reference/api/ (Dates header) "For example, http://graph.facebook.com/platform/feed?date_format=U returns the Platform page's feed, with unixtime-formatted dates." Because it said unitxtime I assumed miliSeconds. Thanks. B – Budius Sep 21 '12 at 12:40
1

Check this post. Seems like similar. It may help you.

Date d = new Date(1220227200 * 1000);
Community
  • 1
  • 1
Eldhose M Babu
  • 14,382
  • 8
  • 39
  • 44