我收到以下错误 “E / Sync:java.text.ParseException:Unparseable date:”“(在偏移0处)” 我在堆栈溢出中经历了很多解决方案。但无法获得适当的解决方案
Following is the code:
public void execute() {
if (mTableName.contentEquals("removed")) {
String query = "Select * from removed";
Cursor cursor = LODatabaseUtility.getInstance().cursorFromQuery(
query);
List<String> tableName = LODatabaseUtility.getInstance()
.dataListfromCursor(cursor, "table_name");
cursor = LODatabaseUtility.getInstance().cursorFromQuery(query);
List<String> number = LODatabaseUtility.getInstance()
.dataListfromCursor(cursor, "number");
cursor = LODatabaseUtility.getInstance().cursorFromQuery(query);
List<String> removedTimestamp = LODatabaseUtility.getInstance()
.dataListfromCursor(cursor, "timestamp");
if (number.size() == 0 || tableName.size() == 0) {
cursor.close();
}
for (int i = 0; i < tableName.size(); ++i) {
query = "Select timestamp from " + tableName.get(i) + " where "
+ tableName.get(i) + "_id = " + number.get(i);
cursor = LODatabaseUtility.getInstance().cursorFromQuery(query);
String tableTimestamp = LODatabaseUtility.getInstance()
.dataStringfromCursor(cursor);
try {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
Date removedDate, tableDate;
removedDate = df.parse(removedTimestamp.get(i));
tableDate = df.parse(tableTimestamp);
if (removedDate.compareTo(tableDate) > 0) {
query = "Delete from " + tableName.get(i) + " where "
+ tableName.get(i) + "_id = " + number.get(i);
LODatabaseUtility.getInstance().getDatabase()
.execSQL(query);
}
} catch (ParseException e) {
Log.e("Sync", "" + e);
e.printStackTrace();
}
}
cursor.close();
}
getSyncTimeFromServer(mTableName);
}
I get the error pointing to the following line of code:
tableDate = df.parse(tableTimestamp);
仅对于特定表,时间戳值给出错误。对于我有时间戳值的其余表,正确插入值。任何帮助都是有用的