tags:

views:

212

answers:

2

Hi,

I have a FQL statement like this:

String query = "SELECT post_id, actor_id, target_id, created_time, message 
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!

A: 

This can have several causes. Two most possible are:

  1. The created_time is in seconds, while Date#setTime() expects milliseconds. Multiply it by 1000 before setting.

  2. The created_time represents the 24h clock rather than the epoch timestamp as Date 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.

BalusC
A: 

Solution: multiply the Facebook timestamp with 1000. Facebook saves seconds, not milliseconds.

this did the job:

myDate.setTime(wallpost.getCreated_time()*1000); 
smitty