Domanda

In my app i am fetching list of upcoming birthdays, but facing a small issue, not getting current date b'days in a List, see code written by me to get Upcoming birthdays:

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));   
    }

So tell me where i am missing, i don't know how to get today date's b'days in a List....

È stato utile?

Soluzione

same day I found solution, but was little busy, So to get Current Date b'days instead of using today's date in logic, i am using yesterday's date, i did some changes in my code, see below:

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

by using above code you can get current date b'days along with all upcoming facebook friend's birthdays or even more just use >= this in place of > to get past day birthday(s) of your friend(s)

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top