Example usage for twitter4j User getCreatedAt

List of usage examples for twitter4j User getCreatedAt

Introduction

In this page you can find the example usage for twitter4j User getCreatedAt.

Prototype

Date getCreatedAt();

Source Link

Usage

From source file:com.raythos.sentilexo.twitter.domain.QueryResultItemMapper.java

License:Apache License

public static TwitterQueryResultItemAvro mapItem(String queryOwner, String queryName, String queryString,
        Status status) {//from  w  w  w.j ava2 s .co  m
    TwitterQueryResultItemAvro result = new TwitterQueryResultItemAvro();

    if (queryName != null)
        queryName = queryName.toLowerCase();
    if (queryOwner != null)
        queryOwner = queryOwner.toLowerCase();

    result.setQueryName(queryName);
    result.setQueryOwner(queryOwner);
    result.setQuery(queryString);
    result.setStatusId(status.getId());
    result.setText(status.getText());

    result.setRelevantQueryTerms(TwitterUtils.relevantQueryTermsFromStatus(queryString, status));
    result.setLang(status.getLang());

    result.setCreatedAt(status.getCreatedAt().getTime());

    User user = status.getUser();
    result.setUserId(user.getId());
    result.setScreenName(user.getScreenName());
    result.setUserLocation(user.getLocation());
    result.setUserName(user.getName());
    result.setUserDescription(user.getDescription());
    result.setUserIsProtected(user.isProtected());
    result.setUserFollowersCount(user.getFollowersCount());
    result.setUserCreatedAt(user.getCreatedAt().getTime());
    result.setUserCreatedAtAsString(DateTimeUtils.getDateAsText(user.getCreatedAt()));
    result.setCreatedAtAsString(DateTimeUtils.getDateAsText(status.getCreatedAt()));
    result.setUserFriendsCount(user.getFriendsCount());
    result.setUserListedCount(user.getListedCount());
    result.setUserStatusesCount(user.getStatusesCount());
    result.setUserFavoritesCount(user.getFavouritesCount());

    result.setCurrentUserRetweetId(status.getCurrentUserRetweetId());

    result.setInReplyToScreenName(status.getInReplyToScreenName());
    result.setInReplyToStatusId(status.getInReplyToStatusId());
    result.setInReplyToUserId(status.getInReplyToUserId());

    if (status.getGeoLocation() != null) {
        result.setLatitude(status.getGeoLocation().getLatitude());
        result.setLongitude(status.getGeoLocation().getLongitude());
    }

    result.setSource(status.getSource());
    result.setTrucated(status.isTruncated());
    result.setPossiblySensitive(status.isPossiblySensitive());

    result.setRetweet(status.getRetweetedStatus() != null);
    if (result.getRetweet()) {
        result.setRetweetStatusId(status.getRetweetedStatus().getId());
        result.setRetweetedText(status.getRetweetedStatus().getText());
    }
    result.setRetweeted(status.isRetweeted());
    result.setRetweetCount(status.getRetweetCount());
    result.setRetweetedByMe(status.isRetweetedByMe());

    result.setFavoriteCount(status.getFavoriteCount());
    result.setFavourited(status.isFavorited());

    if (status.getPlace() != null) {
        result.setPlace(status.getPlace().getFullName());
    }

    Scopes scopesObj = status.getScopes();
    if (scopesObj != null) {
        List scopes = Arrays.asList(scopesObj.getPlaceIds());
        result.setScopes(scopes);
    }
    return result;
}

From source file:com.twitstreet.db.data.Stock.java

License:Open Source License

public Stock(twitter4j.User twUser) {
    this.setId(twUser.getId());
    this.setLongName(twUser.getName());
    this.setName(twUser.getScreenName());
    this.setTotal(twUser.getFollowersCount());
    this.setPictureUrl(twUser.getProfileImageURL().toExternalForm());
    this.setSold(0.0D);
    this.setVerified(twUser.isVerified());
    this.setLanguage(twUser.getLang());
    this.setCreatedAt(twUser.getCreatedAt());
    this.setLocation(twUser.getLocation());
    this.setDescription(twUser.getDescription());
}

From source file:de.jetwick.data.JUser.java

License:Apache License

/**
 * This method refreshes the properties of this user by the specified
 * Twitter4j user// ww w  . ja v  a 2  s  .c o  m
 * @param user
 */
public Status updateFieldsBy(User user) {
    twitterId = user.getId();
    setProtected(user.isProtected());
    setTwitterCreatedAt(user.getCreatedAt());
    setDescription(user.getDescription());
    addLanguage(user.getLang());
    setLocation(TwitterSearch.toStandardLocation(user.getLocation()));
    setRealName(user.getName());

    // user.getFollowersCount();
    // user.getFriendsCount();
    // user.getTimeZone()

    if (user.getProfileImageURL() != null)
        setProfileImageUrl(user.getProfileImageURL().toString());

    if (user.getURL() != null)
        setWebUrl(user.getURL().toString());

    setFollowersCount(user.getFollowersCount());
    setFriendsCount(user.getFriendsCount());
    return user.getStatus();
}

From source file:de.vanita5.twittnuker.model.ParcelableUser.java

License:Open Source License

public ParcelableUser(final User user, final long account_id, final long position) {
    this.position = position;
    this.account_id = account_id;
    final URLEntity[] urls_url_entities = user.getURLEntities();
    id = user.getId();/*w w w  . j a  va2 s. com*/
    created_at = getTime(user.getCreatedAt());
    is_protected = user.isProtected();
    is_verified = user.isVerified();
    name = user.getName();
    screen_name = user.getScreenName();
    description_plain = user.getDescription();
    description_html = formatUserDescription(user);
    description_expanded = formatExpandedUserDescription(user);
    location = user.getLocation();
    profile_image_url = ParseUtils.parseString(user.getProfileImageUrlHttps());
    profile_banner_url = user.getProfileBannerImageUrl();
    url = ParseUtils.parseString(user.getURL());
    url_expanded = url != null && urls_url_entities != null && urls_url_entities.length > 0
            ? ParseUtils.parseString(urls_url_entities[0].getExpandedURL())
            : null;
    is_follow_request_sent = user.isFollowRequestSent();
    followers_count = user.getFollowersCount();
    friends_count = user.getFriendsCount();
    statuses_count = user.getStatusesCount();
    favorites_count = user.getFavouritesCount();
    listed_count = user.getListedCount();
    is_cache = false;
    is_following = user.isFollowing();
    description_unescaped = toPlainText(description_html);
}

From source file:de.vanita5.twittnuker.util.ContentValuesCreator.java

License:Open Source License

public static ContentValues makeCachedUserContentValues(final User user) {
    if (user == null || user.getId() <= 0)
        return null;
    final String profile_image_url = ParseUtils.parseString(user.getProfileImageUrlHttps());
    final String url = ParseUtils.parseString(user.getURL());
    final URLEntity[] urls = user.getURLEntities();
    final ContentValues values = new ContentValues();
    values.put(CachedUsers.USER_ID, user.getId());
    values.put(CachedUsers.NAME, user.getName());
    values.put(CachedUsers.SCREEN_NAME, user.getScreenName());
    values.put(CachedUsers.PROFILE_IMAGE_URL, profile_image_url);
    values.put(CachedUsers.CREATED_AT, user.getCreatedAt().getTime());
    values.put(CachedUsers.IS_PROTECTED, user.isProtected());
    values.put(CachedUsers.IS_VERIFIED, user.isVerified());
    values.put(CachedUsers.IS_FOLLOWING, user.isFollowing());
    values.put(CachedUsers.FAVORITES_COUNT, user.getFavouritesCount());
    values.put(CachedUsers.FOLLOWERS_COUNT, user.getFollowersCount());
    values.put(CachedUsers.FRIENDS_COUNT, user.getFriendsCount());
    values.put(CachedUsers.STATUSES_COUNT, user.getStatusesCount());
    values.put(CachedUsers.LISTED_COUNT, user.getListedCount());
    values.put(CachedUsers.LOCATION, user.getLocation());
    values.put(CachedUsers.DESCRIPTION_PLAIN, user.getDescription());
    values.put(CachedUsers.DESCRIPTION_HTML, Utils.formatUserDescription(user));
    values.put(CachedUsers.DESCRIPTION_EXPANDED, Utils.formatExpandedUserDescription(user));
    values.put(CachedUsers.URL, url);
    values.put(CachedUsers.URL_EXPANDED,
            url != null && urls != null && urls.length > 0 ? ParseUtils.parseString(urls[0].getExpandedURL())
                    : null);/*w w  w. j av a  2 s  . c  o m*/
    values.put(CachedUsers.PROFILE_BANNER_URL, user.getProfileBannerImageUrl());
    return values;
}

From source file:io.rakam.datasource.twitter.TweetProcessor.java

License:Apache License

@Override
public void onStatus(Status status) {
    Map<String, Object> map = new HashMap<>();

    GeoLocation geoLocation = status.getGeoLocation();
    if (geoLocation != null) {
        map.put("latitude", geoLocation.getLatitude());
        map.put("longitude", geoLocation.getLongitude());
    }// ww w . j av  a2 s .c om

    map.put("_time", status.getCreatedAt().getTime());
    Place place = status.getPlace();
    if (place != null) {
        map.put("country_code", place.getCountryCode());
        map.put("place", place.getName());
        map.put("place_type", place.getPlaceType());
        map.put("place_id", place.getId());
    }

    User user = status.getUser();
    map.put("_user", user.getId());
    map.put("user_lang", user.getLang());
    map.put("user_created", user.getCreatedAt());
    map.put("user_followers", user.getFollowersCount());
    map.put("user_status_count", user.getStatusesCount());
    map.put("user_verified", user.isVerified());

    map.put("id", status.getId());
    map.put("is_reply", status.getInReplyToUserId() > -1);
    map.put("is_retweet", status.isRetweet());
    map.put("has_media", status.getMediaEntities().length > 0);
    map.put("urls",
            Arrays.stream(status.getURLEntities()).map(URLEntity::getText).collect(Collectors.toList()));
    map.put("hashtags", Arrays.stream(status.getHashtagEntities()).map(HashtagEntity::getText)
            .collect(Collectors.toList()));
    map.put("user_mentions", Arrays.stream(status.getUserMentionEntities()).map(UserMentionEntity::getText)
            .collect(Collectors.toList()));
    map.put("language", "und".equals(status.getLang()) ? null : status.getLang());
    map.put("is_positive", classifier.isPositive(status.getText()));

    Event event = new Event().properties(map).collection(collection);
    buffer.add(event);

    commitIfNecessary();
}

From source file:org.encuestame.social.api.templates.TwitterAPITemplate.java

License:Apache License

@Override
public SocialUserProfile getProfile() throws Exception {
    final SocialUserProfile profile = new SocialUserProfile();
    User user = this.getUser();
    profile.setId(String.valueOf(user.getId()));
    profile.setCreatedAt(user.getCreatedAt());
    profile.setProfileUrl("http://www.twitter.com/" + user.getScreenName());
    profile.setName(user.getName());/*from w w  w .  jav  a2 s . c o  m*/
    profile.setScreenName(user.getScreenName());
    profile.setUsername(user.getScreenName());
    profile.setProfileImageUrl(user.getProfileImageURL().toString());
    profile.setDescription(user.getDescription());
    profile.setCreatedAt(user.getCreatedAt());
    profile.setLocation(user.getLocation());
    return profile;
}

From source file:org.getlantern.firetweet.model.ParcelableUser.java

License:Open Source License

public ParcelableUser(final User user, final long account_id, final long position) {
    this.position = position;
    this.account_id = account_id;
    final URLEntity[] urls_url_entities = user.getURLEntities();
    id = user.getId();/*from  ww  w  .  j  av  a 2s  .  c om*/
    created_at = user.getCreatedAt().getTime();
    is_protected = user.isProtected();
    is_verified = user.isVerified();
    name = user.getName();
    screen_name = user.getScreenName();
    description_plain = user.getDescription();
    description_html = TwitterContentUtils.formatUserDescription(user);
    description_expanded = TwitterContentUtils.formatExpandedUserDescription(user);
    description_unescaped = HtmlEscapeHelper.toPlainText(description_html);
    location = user.getLocation();
    profile_image_url = user.getProfileImageUrlHttps();
    profile_banner_url = user.getProfileBannerImageUrl();
    url = user.getURL();
    url_expanded = url != null && urls_url_entities != null && urls_url_entities.length > 0
            ? urls_url_entities[0].getExpandedURL()
            : null;
    is_follow_request_sent = user.isFollowRequestSent();
    followers_count = user.getFollowersCount();
    friends_count = user.getFriendsCount();
    statuses_count = user.getStatusesCount();
    favorites_count = user.getFavouritesCount();
    listed_count = user.getListedCount();
    is_following = user.isFollowing();
    background_color = ParseUtils.parseColor("#" + user.getProfileBackgroundColor(), 0);
    link_color = ParseUtils.parseColor("#" + user.getProfileLinkColor(), 0);
    text_color = ParseUtils.parseColor("#" + user.getProfileTextColor(), 0);
    is_cache = false;
    is_basic = false;
}

From source file:org.getlantern.firetweet.util.ContentValuesCreator.java

License:Open Source License

public static ContentValues createCachedUser(final User user) {
    if (user == null || user.getId() <= 0)
        return null;
    final String profile_image_url = user.getProfileImageUrlHttps();
    final String url = user.getURL();
    final URLEntity[] urls = user.getURLEntities();
    final ContentValues values = new ContentValues();
    values.put(CachedUsers.USER_ID, user.getId());
    values.put(CachedUsers.NAME, user.getName());
    values.put(CachedUsers.SCREEN_NAME, user.getScreenName());
    values.put(CachedUsers.PROFILE_IMAGE_URL, profile_image_url);
    values.put(CachedUsers.PROFILE_BANNER_URL, user.getProfileBannerImageUrl());
    values.put(CachedUsers.CREATED_AT, user.getCreatedAt().getTime());
    values.put(CachedUsers.IS_PROTECTED, user.isProtected());
    values.put(CachedUsers.IS_VERIFIED, user.isVerified());
    values.put(CachedUsers.IS_FOLLOWING, user.isFollowing());
    values.put(CachedUsers.FAVORITES_COUNT, user.getFavouritesCount());
    values.put(CachedUsers.FOLLOWERS_COUNT, user.getFollowersCount());
    values.put(CachedUsers.FRIENDS_COUNT, user.getFriendsCount());
    values.put(CachedUsers.STATUSES_COUNT, user.getStatusesCount());
    values.put(CachedUsers.LISTED_COUNT, user.getListedCount());
    values.put(CachedUsers.LOCATION, user.getLocation());
    values.put(CachedUsers.DESCRIPTION_PLAIN, user.getDescription());
    values.put(CachedUsers.DESCRIPTION_HTML, TwitterContentUtils.formatUserDescription(user));
    values.put(CachedUsers.DESCRIPTION_EXPANDED, TwitterContentUtils.formatExpandedUserDescription(user));
    values.put(CachedUsers.URL, url);
    if (url != null && urls != null && urls.length > 0) {
        values.put(CachedUsers.URL_EXPANDED, urls[0].getExpandedURL());
    }//from  ww  w.  j  av a 2  s.  c om
    values.put(CachedUsers.BACKGROUND_COLOR, ParseUtils.parseColor("#" + user.getProfileBackgroundColor(), 0));
    values.put(CachedUsers.LINK_COLOR, ParseUtils.parseColor("#" + user.getProfileLinkColor(), 0));
    values.put(CachedUsers.TEXT_COLOR, ParseUtils.parseColor("#" + user.getProfileTextColor(), 0));
    return values;
}

From source file:org.mariotaku.twidere.model.ParcelableUser.java

License:Open Source License

public ParcelableUser(final User user, final long account_id, final long position) {
    this.position = position;
    this.account_id = account_id;
    final URLEntity[] urls_url_entities = user.getURLEntities();
    id = user.getId();//from ww w .ja v  a 2s .c o  m
    created_at = user.getCreatedAt().getTime();
    is_protected = user.isProtected();
    is_verified = user.isVerified();
    name = user.getName();
    screen_name = user.getScreenName();
    description_plain = user.getDescription();
    description_html = TwitterContentUtils.formatUserDescription(user);
    description_expanded = TwitterContentUtils.formatExpandedUserDescription(user);
    description_unescaped = HtmlEscapeHelper.toPlainText(description_html);
    location = user.getLocation();
    profile_image_url = user.getProfileImageUrlHttps();
    profile_banner_url = user.getProfileBannerImageUrl();
    url = user.getURL();
    url_expanded = url != null && urls_url_entities != null && urls_url_entities.length > 0
            ? urls_url_entities[0].getExpandedURL()
            : null;
    is_follow_request_sent = user.isFollowRequestSent();
    followers_count = user.getFollowersCount();
    friends_count = user.getFriendsCount();
    statuses_count = user.getStatusesCount();
    favorites_count = user.getFavouritesCount();
    listed_count = user.getListedCount();
    media_count = user.getMediaCount();
    is_following = user.isFollowing();
    background_color = ParseUtils.parseColor("#" + user.getProfileBackgroundColor(), 0);
    link_color = ParseUtils.parseColor("#" + user.getProfileLinkColor(), 0);
    text_color = ParseUtils.parseColor("#" + user.getProfileTextColor(), 0);
    is_cache = false;
    is_basic = false;
}