mirror of
https://github.com/GeorgH93/Minepacks.git
synced 2025-01-07 19:28:11 +01:00
Move sqliteDateFormat into the only class using it
This commit is contained in:
parent
90921384a2
commit
dcf4249afb
@ -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())));
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user