The change
From 3.1.0, the times on Entry and Group are java.time.Instant instead of java.util.Date:
getCreationTime(), getLastModificationTime(), getLastAccessTime() and getExpiryTime() return Instant;
setExpiryTime(...) takes an Instant.
This is a breaking change, made in 3.1.0 along with the move to Java 17.
Why
The Date signatures date from when KeePassJava2 supported Java 7, which has no java.time, and were never updated. The basic implementation already kept Instants internally and converted them to Date at the interface. Instant is immutable and works with the rest of java.time.
Instant rather than ZonedDateTime: the formats don't store a time zone. KDBX 3.1 times are ISO 8601 in UTC, KDBX 4 times are seconds since 0001-01-01T00:00:00Z, and KDB times are treated as UTC. A Date is also a point in time without a zone, so the meaning is unchanged; only the type changes. The times in files are the same as in 3.0.0.
Upgrading
Where code needs a Date, convert at the call:
Date created = Date.from(entry.getCreationTime());
entry.setExpiryTime(expiryDate.toInstant());
The readme has a section "Upgrading from 3.0 to 3.1".
Also changed
- The KDBX (Jackson) model, its converters and the KDB and Basic implementations use
Instant throughout.
Helpers.toDate/fromDate/fromDateV3/fromDateV4/baseDate are now toInstant/fromInstant/fromInstantV3/fromInstantV4/baseInstant.
Done in 07ba898, merged into v3-develop. The SPI planned in #110 uses Instant too.
The change
From 3.1.0, the times on
EntryandGrouparejava.time.Instantinstead ofjava.util.Date:getCreationTime(),getLastModificationTime(),getLastAccessTime()andgetExpiryTime()returnInstant;setExpiryTime(...)takes anInstant.This is a breaking change, made in 3.1.0 along with the move to Java 17.
Why
The
Datesignatures date from when KeePassJava2 supported Java 7, which has nojava.time, and were never updated. Thebasicimplementation already keptInstants internally and converted them toDateat the interface.Instantis immutable and works with the rest ofjava.time.Instantrather thanZonedDateTime: the formats don't store a time zone. KDBX 3.1 times are ISO 8601 in UTC, KDBX 4 times are seconds since 0001-01-01T00:00:00Z, and KDB times are treated as UTC. ADateis also a point in time without a zone, so the meaning is unchanged; only the type changes. The times in files are the same as in 3.0.0.Upgrading
Where code needs a
Date, convert at the call:The readme has a section "Upgrading from 3.0 to 3.1".
Also changed
Instantthroughout.Helpers.toDate/fromDate/fromDateV3/fromDateV4/baseDateare nowtoInstant/fromInstant/fromInstantV3/fromInstantV4/baseInstant.Done in 07ba898, merged into
v3-develop. The SPI planned in #110 usesInstanttoo.