To be safe, avoid static DateFormat even in single-thread Android context

This commit is contained in:
Sean Owen 2014-04-22 18:44:17 +01:00
parent a9cf1e91ec
commit 002aa47e01

View file

@ -67,8 +67,6 @@ public final class HistoryManager {
private static final String[] ID_COL_PROJECTION = { DBHelper.ID_COL };
private static final String[] ID_DETAIL_COL_PROJECTION = { DBHelper.ID_COL, DBHelper.DETAILS_COL };
private static final DateFormat EXPORT_DATE_TIME_FORMAT =
DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
private final Activity activity;
@ -286,6 +284,7 @@ public final class HistoryManager {
null, null, null, null,
DBHelper.TIMESTAMP_COL + " DESC");
DateFormat format = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
StringBuilder historyText = new StringBuilder(1000);
while (cursor.moveToNext()) {
@ -297,7 +296,7 @@ public final class HistoryManager {
// Add timestamp again, formatted
long timestamp = cursor.getLong(3);
historyText.append('"').append(massageHistoryField(
EXPORT_DATE_TIME_FORMAT.format(new Date(timestamp)))).append("\",");
format.format(new Date(timestamp)))).append("\",");
// Above we're preserving the old ordering of columns which had formatted data in position 5