Android 显示即将到来的Facebook好友生日

Android 显示即将到来的Facebook好友生日,android,facebook,Android,Facebook,尽管如此,我还是得到了从1月到12月的Facebook好友列表,按升序排列,如下图所示: 但现在我想以即将到来的生日的形式显示Facebook好友列表,如: 最近在顶部 我正在使用以下查询获取朋友列表: Log.d(LOG_TAG, "requestFriends(" + ")"); Date date = new Date(); String current_date = null; SimpleDateFormat dateFormatter = new Sim

尽管如此,我还是得到了从1月到12月的Facebook好友列表,按升序排列,如下图所示:

但现在我想以即将到来的生日的形式显示Facebook好友列表,如:

最近在顶部

我正在使用以下查询获取朋友列表:

   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";        

请告诉我应该使用什么查询来获取即将到来的B'days列表

此查询将获取登录用户帐户中所有好友的列表:

SELECT uid, name, birthday_date FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=me()) ORDER BY birthday_date ASC
这样做的陷阱是,你需要检查用户是否在他们的Facebook帐户中输入了他/她的生日

一个更好的查询至少是我认为更好的:

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
这一个只得到在Facebook账户中填写生日信息的用户列表。通过使用ORDER BY Birth_date,他们总是将即将到来的生日排在结果集中的最前面,一直排到最后一个

这其中的陷阱是,我从来没有使用第二个查询得到过整整几年的生日,请随意测试一下。所以在我的应用程序中,我一次调用6个月的数据。这一直都很精确,而且非常准确

我想,第二个查询将适合您的目的,因为您需要在列表的顶部显示即将到来的生日。为了确保您始终获得当前日期和月份以获得准确的结果,请使用此示例,通过简单的谷歌搜索,您将获得更多信息以获得当前日期和月份:

然后,连接一个字符串并将该实例作为查询传递


注意:查询中使用的月份和日期必须始终为两位数。

您需要查找多少天或月份birthdays@CaptainAmerica我不想知道有多少天或几个月,我只想在上面显示即将到来的生日。。。