Use the same DateFormat for the DB and XML parsing, English locale
This commit is contained in:
parent
fe41108ed6
commit
8411dd4f9c
@ -548,7 +548,8 @@ public class DB {
|
||||
|
||||
// The date format used for storing dates (e.g. lastupdated, added) in the
|
||||
// database.
|
||||
private SimpleDateFormat mDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
public static SimpleDateFormat dateFormat = new SimpleDateFormat(
|
||||
"yyyy-MM-dd", Locale.ENGLISH);
|
||||
|
||||
private DB(Context ctx) {
|
||||
|
||||
@ -740,10 +741,10 @@ public class DB {
|
||||
app.curVercode = c.getInt(9);
|
||||
String sAdded = c.getString(10);
|
||||
app.added = (sAdded == null || sAdded.length() == 0) ? null
|
||||
: mDateFormat.parse(sAdded);
|
||||
: dateFormat.parse(sAdded);
|
||||
String sLastUpdated = c.getString(11);
|
||||
app.lastUpdated = (sLastUpdated == null || sLastUpdated
|
||||
.length() == 0) ? null : mDateFormat
|
||||
.length() == 0) ? null : dateFormat
|
||||
.parse(sLastUpdated);
|
||||
app.compatible = c.getInt(12) == 1;
|
||||
app.ignoreAllUpdates = c.getInt(13) == 1;
|
||||
@ -823,7 +824,7 @@ public class DB {
|
||||
apk.minSdkVersion = c.getInt(6);
|
||||
String sApkAdded = c.getString(7);
|
||||
apk.added = (sApkAdded == null || sApkAdded.length() == 0) ? null
|
||||
: mDateFormat.parse(sApkAdded);
|
||||
: dateFormat.parse(sApkAdded);
|
||||
apk.features = CommaSeparatedList.make(c.getString(8));
|
||||
apk.nativecode = CommaSeparatedList.make(c.getString(9));
|
||||
apk.compatible = compatible;
|
||||
@ -1147,10 +1148,10 @@ public class DB {
|
||||
values.put("dogecoinAddr", upapp.detail_dogecoinAddr);
|
||||
values.put("flattrID", upapp.detail_flattrID);
|
||||
values.put("added",
|
||||
upapp.added == null ? "" : mDateFormat.format(upapp.added));
|
||||
upapp.added == null ? "" : dateFormat.format(upapp.added));
|
||||
values.put(
|
||||
"lastUpdated",
|
||||
upapp.added == null ? "" : mDateFormat
|
||||
upapp.added == null ? "" : dateFormat
|
||||
.format(upapp.lastUpdated));
|
||||
values.put("curVersion", upapp.curVersion);
|
||||
values.put("curVercode", upapp.curVercode);
|
||||
@ -1195,7 +1196,7 @@ public class DB {
|
||||
values.put("apkName", upapk.apkName);
|
||||
values.put("minSdkVersion", upapk.minSdkVersion);
|
||||
values.put("added",
|
||||
upapk.added == null ? "" : mDateFormat.format(upapk.added));
|
||||
upapk.added == null ? "" : dateFormat.format(upapk.added));
|
||||
values.put("permissions",
|
||||
CommaSeparatedList.str(upapk.detail_permissions));
|
||||
values.put("features", CommaSeparatedList.str(upapk.features));
|
||||
@ -1235,7 +1236,7 @@ public class DB {
|
||||
repo.lastetag = c.getString(9);
|
||||
try {
|
||||
repo.lastUpdated = c.getString(10) != null ?
|
||||
mDateFormat.parse( c.getString(10)) :
|
||||
dateFormat.parse( c.getString(10)) :
|
||||
null;
|
||||
} catch (ParseException e) {
|
||||
Log.e("FDroid", "Error parsing date " + c.getString(10));
|
||||
@ -1350,7 +1351,7 @@ public class DB {
|
||||
*/
|
||||
public void refreshLastUpdates() {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put("lastUpdated", mDateFormat.format(new Date()));
|
||||
values.put("lastUpdated", dateFormat.format(new Date()));
|
||||
db.update(TABLE_REPO, values, "inuse = 1",
|
||||
new String[] {});
|
||||
}
|
||||
@ -1358,7 +1359,7 @@ public class DB {
|
||||
public void writeLastEtag(Repo repo) {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put("lastetag", repo.lastetag);
|
||||
values.put("lastUpdated", mDateFormat.format(new Date()));
|
||||
values.put("lastUpdated", dateFormat.format(new Date()));
|
||||
db.update(TABLE_REPO, values, "address = ?",
|
||||
new String[] { repo.address });
|
||||
}
|
||||
|
@ -19,19 +19,15 @@
|
||||
|
||||
package org.fdroid.fdroid;
|
||||
|
||||
import android.content.*;
|
||||
import android.content.res.Configuration;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.*;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.util.Log;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.LayoutInflater;
|
||||
@ -39,6 +35,11 @@ import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.*;
|
||||
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.support.v4.view.ViewPager;
|
||||
|
||||
import org.fdroid.fdroid.compat.TabManager;
|
||||
import org.fdroid.fdroid.views.AppListFragmentPageAdapter;
|
||||
|
||||
|
@ -26,7 +26,6 @@ import org.xml.sax.SAXException;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -61,10 +60,6 @@ public class RepoXMLHandler extends DefaultHandler {
|
||||
private int progressCounter = 0;
|
||||
private ProgressListener progressListener;
|
||||
|
||||
|
||||
// The date format used in the repo XML file.
|
||||
private SimpleDateFormat mXMLDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
private int totalAppCount;
|
||||
|
||||
public RepoXMLHandler(DB.Repo repo, List<DB.App> appsList, ProgressListener listener) {
|
||||
@ -162,7 +157,7 @@ public class RepoXMLHandler extends DefaultHandler {
|
||||
}
|
||||
} else if (curel.equals("added")) {
|
||||
try {
|
||||
curapk.added = str.length() == 0 ? null : mXMLDateFormat
|
||||
curapk.added = str.length() == 0 ? null : DB.dateFormat
|
||||
.parse(str);
|
||||
} catch (ParseException e) {
|
||||
curapk.added = null;
|
||||
@ -209,7 +204,7 @@ public class RepoXMLHandler extends DefaultHandler {
|
||||
curapp.detail_trackerURL = str;
|
||||
} else if (curel.equals("added")) {
|
||||
try {
|
||||
curapp.added = str.length() == 0 ? null : mXMLDateFormat
|
||||
curapp.added = str.length() == 0 ? null : DB.dateFormat
|
||||
.parse(str);
|
||||
} catch (ParseException e) {
|
||||
curapp.added = null;
|
||||
@ -217,7 +212,7 @@ public class RepoXMLHandler extends DefaultHandler {
|
||||
} else if (curel.equals("lastupdated")) {
|
||||
try {
|
||||
curapp.lastUpdated = str.length() == 0 ? null
|
||||
: mXMLDateFormat.parse(str);
|
||||
: DB.dateFormat.parse(str);
|
||||
} catch (ParseException e) {
|
||||
curapp.lastUpdated = null;
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ import java.io.OutputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Formatter;
|
||||
import java.util.Locale;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
@ -44,7 +45,7 @@ public final class Utils {
|
||||
"%.0f B", "%.0f KiB", "%.1f MiB", "%.2f GiB" };
|
||||
|
||||
public static final SimpleDateFormat LOG_DATE_FORMAT =
|
||||
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ENGLISH);
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user