Skip to content

[Feature]: Change java.util.Date to java.time.LocalDateTime in Clock API #1686

Closed as not planned

Description

@lubomsky

🚀 Feature Request

Implementing code using Clock is not as pleasant as it could be.

Example

Now, I have to write something like this:

Instant instant = Instant.now().plus(10, ChronoUnit.MINUTES);
Date date = Date.from(instant);

page.clock().setSystemTime(date)

But I would like to write just like this:

page.clock().setSystemTime(LocalDateTime.now().plusMinutes(10))

Motivation

To use more modern and more convenient java.

First article

Second article

Activity

  1. jhyot commented on Nov 28, 2024

    @jhyot

    Definitely 100% support for this. Please don't use the very old and broken Date API, modern code should always use the java.time API.

  2. yury-s commented on Jun 19, 2026

    @yury-s
    Member

    Thanks for the suggestion. We prototyped it (#1937) but decided not to expand the Clock API for this.

    LocalDateTime has no time zone, so it's a poor fit for an absolute clock time — it'd force a hidden systemDefault() conversion. And the workaround is a one-liner today: page.clock().setSystemTime(Date.from(localDateTime.toInstant(ZoneOffset.UTC))).

    Closing as not planned.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions