Migrate dbWarehouseHandler.java from JodaTime to java.time.*
Completed migration of JodaTime references in dbWarehouseHandler.java:
This commit is contained in:
1 parent
70b941239a
commit
8d6457b91c
2 files changed
+91
-5
No files matched your search
@@ -0,0 +1,86 @@
|
||||
# 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
|
||||
1. Import statement: `import org.joda.time.DateTime;`
|
||||
2. Method parameter: `DateTime upgradeDate` in method signature (line 58)
|
||||
3. Method parameter: `DateTime date` in method signature (line 490)
|
||||
4. Usage of getMillis() method: `upgradeDate.getMillis()` (line 79)
|
||||
5. Usage of getMillis() method: `date.getMillis()` (line 501)
|
||||
|
||||
## Migration Strategy
|
||||
|
||||
### Step 1: Update Import Statement
|
||||
Replace:
|
||||
```java
|
||||
import org.joda.time.DateTime;
|
||||
```
|
||||
With:
|
||||
```java
|
||||
import java.time.Instant;
|
||||
```
|
||||
|
||||
### Step 2: Update Method Signatures
|
||||
Replace:
|
||||
```java
|
||||
DateTime upgradeDate
|
||||
```
|
||||
With:
|
||||
```java
|
||||
Instant upgradeDate
|
||||
```
|
||||
|
||||
Replace:
|
||||
```java
|
||||
DateTime date
|
||||
```
|
||||
With:
|
||||
```java
|
||||
Instant date
|
||||
```
|
||||
|
||||
### Step 3: Update Method Calls
|
||||
Replace:
|
||||
```java
|
||||
upgradeDate.getMillis()
|
||||
```
|
||||
With:
|
||||
```java
|
||||
upgradeDate.toEpochMilli()
|
||||
```
|
||||
|
||||
Replace:
|
||||
```java
|
||||
date.getMillis()
|
||||
```
|
||||
With:
|
||||
```java
|
||||
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
|
||||
|
||||
1. Update import statement from `org.joda.time.DateTime` to `java.time.Instant`
|
||||
2. Update method signature for `upgradeDate` parameter from `DateTime` to `Instant`
|
||||
3. Update method signature for `date` parameter from `DateTime` to `Instant`
|
||||
4. Replace `upgradeDate.getMillis()` with `upgradeDate.toEpochMilli()`
|
||||
5. Replace `date.getMillis()` with `date.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.Timestamp` constructor accepts milliseconds
|
||||
- Network packet structure remains the same (no serialization changes needed)
|
||||
- Thread safety improvements from using java.time.* classes
|
||||
Reference in new issue
Block a user