显示未来的Facebook好友生日 [英] Show Upcoming Facebook Friends Birthdays

查看:524
本文介绍了显示未来的Facebook好友生日的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不过我得到的名单 Facebook好友中的一月表格至12月升序的,见下图:

Still i am getting List of Facebook Friends in Form of January to December in Ascending order, see below image:

但现在我想告诉Facebook的好友列表中的表格的近期生日的一样:

But now i want to show List of Facebook Friends in Form of Upcoming Birthdays Like:

最近通话上方

我使用下面的查询获取好友列表:

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

请告诉我该怎么查询我应该用它来获取名单即将B'days

Please tell me what query i should use to fetch List in Form of Upcoming 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

这样做的缺陷是,你将需要检查,如果用户输入他/她的生日在他们的Facebook账户。

The pitfall of this is, you will need to check if the user has entered his/her birthday in their Facebook accounts.

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

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

这一个得到谁在他们的Facebook账户填补了他们的生日的用户只需名单。而配合使用的ORDER BY birthday_date ,他们永远是在顶部会一路下滑到最后一个结果集中在即将到来的生日。

This one gets just the list of users who have filled in their birthday's in their Facebook accounts. 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.

这样做的缺陷是,,并随时进行测试的,我从来没有一次得到了值得使用第二个查询生日的整个年。所以在我的应用程序,我呼吁在6个月的数据的时间。这一直是始终precise和pretty的多,喋喋不休。

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. This has been always precise and pretty much, bang on.

我怀疑,第二个查询将满足你的目的考虑,你需要显示即将到来的生日在列表的顶部。为了确保您始终获得当前的日期和月份为precise因此在任何时候,用这个例子(和一个简单的谷歌搜索或SO搜索会给你更多),以获得当前的日期和月份:

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:

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

然后,连接一字符串,并通过该实例作为查询。

Then, concatenate a String and pass that instance as the query.

注意:月份和查询中使用的日期必须是在任何时候两位数

NOTE: The month and the date used in the query need to be double digits at all times.

这篇关于显示未来的Facebook好友生日的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆