forked from MagicBane/Server
2.3 KiB
2.3 KiB
JodaTime to java.time.* Migration Plan: dbWarehouseHandler.java
Overview
This document outlines the migration of JodaTime references in dbWarehouseHandler.java from org.joda.time.DateTime to java.time.Instant.
Files to be Modified
src/engine/db/handlers/dbWarehouseHandler.java
JodaTime References Found
- Import statement:
import org.joda.time.DateTime; - Method parameter:
DateTime upgradeDatein method signature (line 58) - Method parameter:
DateTime datein method signature (line 490) - Usage of getMillis() method:
upgradeDate.getMillis()(line 79) - Usage of getMillis() method:
date.getMillis()(line 501)
Migration Strategy
Step 1: Update Import Statement
Replace:
import org.joda.time.DateTime;
With:
import java.time.Instant;
Step 2: Update Method Signatures
Replace:
DateTime upgradeDate
With:
Instant upgradeDate
Replace:
DateTime date
With:
Instant date
Step 3: Update Method Calls
Replace:
upgradeDate.getMillis()
With:
upgradeDate.toEpochMilli()
Replace:
date.getMillis()
With:
date.toEpochMilli()
Step 4: Database Timestamp Handling
The database timestamp handling remains the same as java.sql.Timestamp constructor accepts long values (milliseconds since epoch), which can be obtained from Instant.toEpochMilli().
Implementation Plan
- Update import statement from
org.joda.time.DateTimetojava.time.Instant - Update method signature for
upgradeDateparameter fromDateTimetoInstant - Update method signature for
dateparameter fromDateTimetoInstant - Replace
upgradeDate.getMillis()withupgradeDate.toEpochMilli() - Replace
date.getMillis()withdate.toEpochMilli()
Testing Considerations
- Ensure the network packet serialization format remains unchanged
- Verify database operations work correctly with Instant values
- Test warehouse creation and transaction creation functionality
- Confirm that all existing functionality continues to work as expected
Compatibility Notes
- The migration maintains backward compatibility with database operations since
java.sql.Timestampconstructor accepts milliseconds - Network packet structure remains the same (no serialization changes needed)
- Thread safety improvements from using java.time.* classes