From dcf4249afbf64390845e1b3d4ffa95a5793270ed Mon Sep 17 00:00:00 2001 From: GeorgH93 Date: Sun, 1 May 2022 10:53:16 +0200 Subject: [PATCH] Move sqliteDateFormat into the only class using it --- .../Bukkit/Database/Migration/SQLtoSQLMigration.java | 9 ++++++--- .../Bukkit/Database/Migration/ToSQLMigration.java | 5 +---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Migration/SQLtoSQLMigration.java b/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Migration/SQLtoSQLMigration.java index 665266d..2e249eb 100644 --- a/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Migration/SQLtoSQLMigration.java +++ b/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Migration/SQLtoSQLMigration.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 GeorgH93 + * Copyright (C) 2022 GeorgH93 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,6 +26,8 @@ import org.jetbrains.annotations.Nullable; import java.sql.*; +import java.text.DateFormat; +import java.text.SimpleDateFormat; import java.util.Date; @SuppressWarnings("ConstantConditions") @@ -93,13 +95,14 @@ private void migrateBackpack(@NotNull ResultSet backpacksResultSet, @NotNull Pre preparedStatement.setInt(1, backpacksResultSet.getInt((String) FIELD_BP_OWNER.get(oldDb))); preparedStatement.setBytes(2, backpacksResultSet.getBytes((String) FIELD_BP_ITS.get(oldDb))); preparedStatement.setInt(3, backpacksResultSet.getInt((String) FIELD_BP_VERSION.get(oldDb))); + final DateFormat sqliteDateFormat = new SimpleDateFormat("yyyy-MM-dd"); if(oldDb instanceof SQLite) { - preparedStatement.setTimestamp(4, new Timestamp(SQLITE_DATE_FORMAT.parse(backpacksResultSet.getString((String) FIELD_BP_LAST_UPDATE.get(oldDb))).getTime())); + preparedStatement.setTimestamp(4, new Timestamp(sqliteDateFormat.parse(backpacksResultSet.getString((String) FIELD_BP_LAST_UPDATE.get(oldDb))).getTime())); } else { - preparedStatement.setString(4, SQLITE_DATE_FORMAT.format(new Date(backpacksResultSet.getTimestamp((String) FIELD_BP_LAST_UPDATE.get(oldDb)).getTime()))); + preparedStatement.setString(4, sqliteDateFormat.format(new Date(backpacksResultSet.getTimestamp((String) FIELD_BP_LAST_UPDATE.get(oldDb)).getTime()))); } } } \ No newline at end of file diff --git a/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Migration/ToSQLMigration.java b/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Migration/ToSQLMigration.java index 612e6b2..197fe50 100644 --- a/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Migration/ToSQLMigration.java +++ b/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Migration/ToSQLMigration.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 GeorgH93 + * Copyright (C) 2022 GeorgH93 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,8 +31,6 @@ import java.io.File; import java.lang.reflect.Field; import java.lang.reflect.Method; -import java.text.DateFormat; -import java.text.SimpleDateFormat; @SuppressWarnings("ConstantConditions") public abstract class ToSQLMigration extends Migration @@ -45,7 +43,6 @@ public abstract class ToSQLMigration extends Migration protected static final Field FIELD_BP_ITS = Reflection.getField(SQL.class, "fieldBpIts"); protected static final Field FIELD_BP_VERSION = Reflection.getField(SQL.class, "fieldBpVersion"); protected static final Field FIELD_BP_LAST_UPDATE = Reflection.getField(SQL.class, "fieldBpLastUpdate"); - protected static final DateFormat SQLITE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); protected final SQL newDb;