From fdc42a3d5c64a21623a932724a87b939aa414737 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Fri, 18 Nov 2016 09:08:41 +1100 Subject: [PATCH] Seems the new spigot 1.11 sqlite driver has issues parsing timestamps, no idea why. --- .../plot/database/SQLManager.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index 14ec0379d..0d865699b 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -18,7 +18,6 @@ import com.intellectualcrafters.plot.object.comment.PlotComment; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.TaskManager; - import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.PreparedStatement; @@ -26,7 +25,10 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.sql.Timestamp; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -1661,8 +1663,19 @@ public class SQLManager implements AbstractDB { user = UUID.fromString(o); uuids.put(o, user); } - Timestamp timestamp = resultSet.getTimestamp("timestamp"); - long time = timestamp.getTime(); + long time; + try { + Timestamp timestamp = resultSet.getTimestamp("timestamp"); + time = timestamp.getTime(); + } catch (SQLException exception) { + String parsable = resultSet.getString("timestamp"); + try { + time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(parsable).getTime(); + } catch (ParseException e) { + PS.debug("Could not parse date for plot: " + id + " (" + parsable + ")"); + time = System.currentTimeMillis() + id; + } + } Plot p = new Plot(plot_id, user, new HashSet(), new HashSet(), new HashSet(), "", null, null, null, new boolean[]{false, false, false, false}, time, id); HashMap map = newPlots.get(areaid);