简体   繁体   English

显示即将到来的Facebook朋友生日

[英]Show Upcoming Facebook Friends Birthdays

Still i am getting List of Facebook Friends in Form of January to December in Ascending order , see below image: 我仍然以1到12月的形式按升序获取Facebook朋友列表,请参见下图:

But now i want to show List of Facebook Friends in Form of Upcoming Birthdays Like: 但是现在我想以即将到来的生日的形式显示Facebook朋友列表,例如:

Recents on Top 最近的热门

I am using below query to fetch List of Friends: 我正在使用以下查询来获取好友列表:

   Log.d(LOG_TAG, "requestFriends(" + ")");
    Date date = new Date();
    String current_date = null;
    SimpleDateFormat dateFormatter = new SimpleDateFormat("MM-dd-yyyy");
    current_date = dateFormatter.format(date);
    System.out.println("Current Date is:- " + current_date);
    String query = "select name, birthday, uid, pic_square from user where uid in (select uid2 from friend where uid1=me()) and birthday_date>= "
    + current_date + " order by birthday_date";        

Please tell me what query i should use to fetch List in Form of Upcoming B'days 请告诉我我应该使用什么查询来获取即将到来的B'days形式的列表

This query will grab a list of all the friends in the logged in users account: 该查询将获取已登录用户帐户中所有朋友的列表:

SELECT uid, name, birthday_date FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=me()) ORDER BY birthday_date ASC

The pitfall of this is, you will need to check if the user has entered his/her birthday in their Facebook accounts. 这样做的陷阱是,您需要检查用户是否在其Facebook帐户中输入了他/她的生日。

A better query is (at least what I think is better): 更好的查询是(至少我认为更好):

SELECT uid, name, birthday_date FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=me()) AND birthday_date >= '02/01' AND birthday_date <= '07/01' ORDER BY birthday_date ASC

This one gets just the list of users who have filled in their birthday's in their Facebook accounts. 该用户仅获得在其Facebook帐户中填写了生日的用户列表。 And with the use of ORDER BY birthday_date , they will always be with the upcoming birthday at the top going all the way down to the last one in the result set. 使用ORDER BY birthday_date ,它们将始终与即将到来的生日一起出现,一直到结果集中的最后一个生日。

The pitfall of this is, and feel free to test it , I have never once got the entire years worth of birthdays using the second query. 这是一个陷阱,可以随时进行测试 ,我从未使用第二个查询获得过整年的生日。 SO in my application, I call in 6 months of data at a time. 因此,在我的应用程序中,我一次要输入6个月的数据。 This has been always precise and pretty much, bang on. 这一直都是精确的,而且差不多。

I suspect, the second query will suit your purpose considering that you need to show the upcoming birthday at the top of the list. 我怀疑,考虑到您需要在列表顶部显示即将到来的生日,第二个查询将适合您的目的。 To ensure you always get the current date and month for a precise result at all times, use this example (and a simple Google search or SO search will give you more) to get the current date and month: 为确保始终始终获得精确结果的当前日期和月份,请使用以下示例(简单的Google搜索或SO搜索将为您提供更多信息)以获取当前日期和月份:

http://www.asbhtechsolutions.com/android-tutorials/android-get-current-date-and-time http://www.asbhtechsolutions.com/android-tutorials/android-get-current-date-and-time

Then, concatenate a String and pass that instance as the query. 然后,连接一个String并将该实例作为查询传递。

NOTE: The month and the date used in the query need to be double digits at all times . 注意:查询中使用的月份和日期必须始终为两位数

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM