Skip to content

Instantly share code, notes, and snippets.

@hanishi
Last active November 21, 2020 12:43
Show Gist options
  • Save hanishi/1e75b405ee6ada6990ad4a627265092a to your computer and use it in GitHub Desktop.
Save hanishi/1e75b405ee6ada6990ad4a627265092a to your computer and use it in GitHub Desktop.
....
val days = 3
val lastTimestamp = OffsetDateTime
.ofInstant(
Instant
.ofEpochSecond(timestamp),
ZoneId.systemDefault()
)
.truncatedTo(ChronoUnit.DAYS)
val nextScheduleTimestamp = lastTimestamp.plusSeconds(days * 24 * 60 * 60)
val duration = nextScheduleTimestamp.toEpochSecond - OffsetDateTime
.now()
.toEpochSecond
if (duration > 0)
timers.startSingleTimer(
SomeTimer,
SomeMessage,
duration.seconds
)
else
context.self ! SomeMessage
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment