在我的应用程序中,我正在获取即将到来的生日列表,但面对一个小问题,没有在列表中获取当前日期b'days,请参阅我编写的代码以获得即将到来的生日:
public static void requestFriends(FacebookRequest facebookRequest)
{
Log.d(LOG_TAG, "requestFriends(" + ")");
// ----- [start]to get all upcoming birthdays using Variables -----
Calendar cal = Calendar.getInstance();
Date today = cal.getTime();
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd");
String today_formatted = formatter.format(today);
String query = "select name, birthday, uid, pic_square FROM user " +
"WHERE uid in (SELECT uid2 FROM friend WHERE uid1 = me()) AND birthday_date != 'null' " +
"AND birthday_date >= '" + today_formatted + "'ORDER BY birthday_date ASC";
// ----- [end]to get all upcoming birthdays using Variables -----
Bundle params = new Bundle();
params.putString("method", "fql.query");
params.putString("query", query);
FacebookUtility.asyncRunner.request(null, params, new FacebookRequestListener(FacebookRequestListener.FRIENDS, facebookRequest));
}
所以告诉我我在哪里失踪,我不知道如何在名单中获得今天约会的日期......
答案 0 :(得分:0)
当天我找到了解决方案,但有点忙,所以要获得当前日期b'days而不是使用今天的逻辑日期,我使用昨天的日期,我在我的代码中做了一些更改,见下文:
Calendar cal = Calendar.getInstance();
Date today = cal.getTime();
Date oneDayBefore = new Date(today.getTime() - 10);
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd");
String today_formatted = formatter.format(oneDayBefore);
String query = "select name, birthday, uid, pic_square FROM user " +
"WHERE uid in (SELECT uid2 FROM friend WHERE uid1 = me()) AND birthday_date != 'null' " +
"AND birthday_date > '" + today_formatted + "'ORDER BY birthday_date ASC";
通过使用上面的代码,你可以获得当前日期b'days以及所有即将到来的facebook朋友的生日,或者甚至更多只使用> =这代替>过去你朋友的生日