trying to fix date parse errors

This commit is contained in:
Mariotaku Lee 2015-09-02 21:13:40 +08:00
parent 0870731d28
commit 75df2ae7b9
3 changed files with 4 additions and 15 deletions

View File

@ -40,7 +40,8 @@ public class TwitterDateConverter extends StringBasedTypeConverter<Date> {
private final DateFormat mDateFormat;
public TwitterDateConverter() {
mDateFormat = new SimpleDateFormat("EEE MMM d HH:mm:ss z yyyy", Locale.US);
mDateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss ZZZZZ yyyy", Locale.ENGLISH);
mDateFormat.setLenient(true);
mDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
}

View File

@ -632,12 +632,7 @@ public class ParcelableStatus implements Parcelable, Comparable<ParcelableStatus
@Override
public ParcelableStatus newObject(Cursor cursor) {
final long time = System.currentTimeMillis();
final ParcelableStatus status = new ParcelableStatus(cursor, this);
TwitterContentUtils.checkTime(status.timestamp, time);
TwitterContentUtils.checkTime(status.quoted_timestamp, time);
TwitterContentUtils.checkTime(status.retweet_timestamp, time);
return status;
return new ParcelableStatus(cursor, this);
}
@Override

View File

@ -55,6 +55,7 @@ public class TwitterContentUtils {
public static final int TWITTER_BULK_QUERY_COUNT = 100;
private static final long ONE_MINUTE = TimeUnit.MILLISECONDS.convert(1, TimeUnit.MINUTES);
private static final Pattern PATTERN_TWITTER_STATUS_LINK = Pattern.compile("https?://twitter\\.com/(?:#!/)?(\\w+)/status(es)?/(\\d+)");
public static String formatDirectMessageText(final DirectMessage message) {
if (message == null) return null;
@ -173,8 +174,6 @@ public class TwitterContentUtils {
return str.replace("&amp;", "&").replace("&lt;", "<").replace("&gt;", ">");
}
private static final Pattern PATTERN_TWITTER_STATUS_LINK = Pattern.compile("https?://twitter\\.com/(?:#!/)?(\\w+)/status(es)?/(\\d+)");
public static <T extends List<Status>> T getStatusesWithQuoteData(Twitter twitter, @NonNull T list) throws TwitterException {
LongSparseMap<Status> quotes = new LongSparseMap<>();
// Phase 1: collect all statuses contains a status link, and put it in the map
@ -243,10 +242,4 @@ public class TwitterContentUtils {
}
}
public static void checkTime(long that, long current) {
if (that <= 0) return;
if ((that - current) > ONE_MINUTE) {
AbsLogger.error(new Exception("Wrong timestamp " + that + ", current " + current));
}
}
}