Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add java.time support to EJB Timer #95

Open
thatsIch opened this issue Apr 17, 2020 · 0 comments
Open

Add java.time support to EJB Timer #95

thatsIch opened this issue Apr 17, 2020 · 0 comments
Milestone

Comments

@thatsIch
Copy link

EJB provides a subsection for scheduler and timers.

To create a timer you can inject a TimerService like

@Inject
TimerService timerService;

The TimerService provides methods to create single-action timer amonst other ways either by TimerService#createTimer(Date, Serializable) or TimerService#createSingleActionTimer(Date, TimerConfig but none where you can with a java.time parameter like LocalDateTime.

Currently, it is required to convert LocalDateTime or other members of java.time to Date by using converters like

public Date convertToDateViaSqlTimestamp(LocalDateTime dateToConvert) {
    return java.sql.Timestamp.valueOf(dateToConvert);
}

or through java.time.Instant

Date convertToDateViaInstant(LocalDateTime dateToConvert) {
    return java.util.Date
      .from(dateToConvert.atZone(ZoneId.systemDefault())
      .toInstant());
}

It was telegraphed that the alignment from JakartaEE/JavaEE to Java 8+ was an important step and adding support for java.time is part of this.

I suggest adding methods

public Timer createSingleActionTimer(LocalDateTime, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException

and sibling methods to add java.time support to ejb timers.

@smillidge smillidge added this to the Jakarta EE 10 milestone Apr 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants