Skip to content

Use java.time.Instant instead of java.util.Date for Entry and Group times #111

Description

@jorabin

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.

Activity

  1. jorabin commented on Oct 5, 2026

    @jorabin
    OwnerAuthor

    Released in 3.1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions