From bc284a0717ff1ce4340f7b177b46a85505211092 Mon Sep 17 00:00:00 2001 From: Eric Date: Sun, 16 Jun 2019 17:32:27 +0200 Subject: [PATCH] Only use one date format instance --- src/main/java/de/epiceric/shopchest/sql/Database.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/epiceric/shopchest/sql/Database.java b/src/main/java/de/epiceric/shopchest/sql/Database.java index 3054879..b9536a9 100644 --- a/src/main/java/de/epiceric/shopchest/sql/Database.java +++ b/src/main/java/de/epiceric/shopchest/sql/Database.java @@ -38,7 +38,8 @@ import com.zaxxer.hikari.HikariDataSource; public abstract class Database { private static final int DATABASE_VERSION = 2; - private static Set notFoundWorlds = new HashSet<>(); + private final Set notFoundWorlds = new HashSet<>(); + private final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String tableShops; String tableLogs; @@ -147,7 +148,7 @@ public abstract class Database { long time = 0L; try { - time = new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(timestamp).getTime(); + time = dateFormat.parse(timestamp).getTime(); } catch (ParseException e) { plugin.debug("Failed to parse timestamp '" + timestamp + "': Time is set to 0"); plugin.debug(e); @@ -487,7 +488,7 @@ public abstract class Database { long millis = System.currentTimeMillis(); ps.setInt(1, shop.getID()); - ps.setString(2, new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(millis)); + ps.setString(2, dateFormat.format(millis)); ps.setLong(3, millis); ps.setString(4, executor.getName()); ps.setString(5, executor.getUniqueId().toString());