added clock service module
All checks were successful
Build, test and publish the Quarkus libraries / build (push) Successful in 10m19s
All checks were successful
Build, test and publish the Quarkus libraries / build (push) Successful in 10m19s
This commit is contained in:
parent
6e2ce2d489
commit
d4edd00f0f
9 changed files with 161 additions and 26 deletions
|
@ -0,0 +1,18 @@
|
|||
package ch.phoenixtechnologies.quarkus.commons.clock;
|
||||
|
||||
import io.quarkus.arc.DefaultBean;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.enterprise.inject.Produces;
|
||||
|
||||
import java.time.Clock;
|
||||
|
||||
class ClockProducer {
|
||||
|
||||
@Produces
|
||||
@DefaultBean
|
||||
@ApplicationScoped
|
||||
Clock produceClock() {
|
||||
return Clock.systemDefaultZone();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package ch.phoenixtechnologies.quarkus.commons.clock;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
public interface ClockService {
|
||||
|
||||
Instant instant();
|
||||
|
||||
long currentTimeMillis();
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package ch.phoenixtechnologies.quarkus.commons.clock;
|
||||
|
||||
import io.quarkus.arc.DefaultBean;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
|
||||
import java.time.Clock;
|
||||
import java.time.Instant;
|
||||
|
||||
@DefaultBean
|
||||
@ApplicationScoped
|
||||
class ClockServiceImpl implements ClockService {
|
||||
|
||||
private final Clock clock;
|
||||
|
||||
ClockServiceImpl(Clock clock) {
|
||||
this.clock = clock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instant instant() {
|
||||
return clock.instant();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long currentTimeMillis() {
|
||||
return clock.millis();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue