Search code examples
twitter4j

Getting all Tweets from a User, after a certain date


You can get all tweets for a user: via the getUserTimeline() method.

You can also get all tweets after a specific date: sinceId() method.

But I want to combine these two. I want to get all tweets from a certain user, but only those tweets which were posted after a given date. Any ideas on how to do this?


Solution

  • I don't understand why you need sinceId(). getUserTimeline() returns a paginated list of Statuses. For each status in the list, doing status.getCreatedAt() returns a Date which is a Comparable. You can easily compare Date instances with each other and determine if a Date occured after another Date.