I have a FQL statement like this:
String query = "SELECT post_id, actor_id, target_id, created_time, messag开发者_StackOverflowe
FROM stream WHERE source_id in (SELECT target_id FROM connection
WHERE source_id=<userID>) AND is_hidden = 0";
I just wondering what kind of time Facebook gives to me. The result of my statement will be mapped to a wrapper object (wallpost).
myDate.setTime(wallpost.getCreated_time());
gives me no valid date.
Does anyone have an idea what kind of date Facebook returns and how to match it to Date()?
thanks in advance!
This can have several causes. Two most possible are:
The
created_time
is in seconds, whileDate#setTime()
expects milliseconds. Multiply it by 1000 before setting.The
created_time
represents the 24h clock rather than the epoch timestamp asDate
is expecting. Append the timestamp of today on 00:00AM before setting.
To determine the one or other, do a
System.out.println(wallpost.getCreated_time());
and
System.out.println(myDate);
so that you can conclude yourself logically.
Solution: multiply the Facebook timestamp with 1000. Facebook saves seconds, not milliseconds.
this did the job:
myDate.setTime(wallpost.getCreated_time()*1000);
精彩评论