java twitter4j和twitter时间戳处理
根据官方twitter api页面https://dev.twitter.com/overview/api/tweets),每条推文的“created_at”时间戳是根据“创建此推文的UTC时间”编译的
哪个UTC
因为在tweet结构中的User结构下,我找到了创建tweet(https://dev.twitter.com/overview/api/users)的用户的“utc_offset”
因此,我的问题是,如果我能把每个twitt的“CytEdIt”字段独立于所使用的API,如没有偏移的UTC。p>为了确定twitter4j是否会改变这种行为,如果我在意大利运行一个简单的流媒体测试,UTC-1在哪里
String now = new SimpleDateFormat("yyyyMMdd_HHmmss").format(Calendar.getInstance().getTime());
System.out.println("test run at: " + now);
StatusListener listener = new StatusListener(){
@Override
public void onException(Exception ex) {
ex.printStackTrace();
}
@Override
public void onStatus(Status status) {
System.out.println("@" + status.getId() + " - " + status.getCreatedAt().toString());
}
@Override
public void onDeletionNotice(StatusDeletionNotice sdn) {
}
@Override
public void onScrubGeo(long l, long l1) {
}
@Override
public void onStallWarning(StallWarning sw) {
}
@Override
public void onTrackLimitationNotice(int i) {
}
};
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true)
.setOAuthConsumerKey ...
TwitterStream twitterStream = new TwitterStreamFactory(cb.build()).getInstance();
twitterStream.addListener(listener);
twitterStream.sample();
结果我得到了这样的结果:
run:
test run at: 20160921_084244
[Wed Sep 21 08:42:44 CEST 2016]Establishing connection.
[Wed Sep 21 08:42:46 CEST 2016]Connection established.
[Wed Sep 21 08:42:46 CEST 2016]Receiving status stream.
@778484603443113985 - Wed Sep 21 08:42:47 CEST 2016
@778484603443085312 - Wed Sep 21 08:42:47 CEST 2016
@778484603434795008 - Wed Sep 21 08:42:47 CEST 2016
@778484603443154945 - Wed Sep 21 08:42:47 CEST 2016
@778484603438923776 - Wed Sep 21 08:42:47 CEST 2016
@778484603434721280 - Wed Sep 21 08:42:47 CEST 2016
如果很容易注意到推文没有以标准UTC显示,那么twitter4j似乎会根据本地时区自动调整推文
有人能帮我更好地理解吗
共 (0) 个答案