VirtualClock
Works in connection with InteractionService , such that it allows an Interaction to run with its own simulated (or actual) time.
API
interface VirtualClock {
Instant nowAsInstant() (1)
VirtualClock system() (2)
VirtualClock nowAt(Instant virtualNow) (3)
VirtualClock nowAt(java.time.@NonNull LocalDate virtualNow) (4)
VirtualClock nowAt(java.time.@NonNull LocalDateTime virtualNow)
VirtualClock nowAt(java.time.@NonNull OffsetDateTime virtualNow)
VirtualClock nowAt(java.time.@NonNull ZonedDateTime virtualNow)
VirtualClock nowAt(java.util.@NonNull Date virtualNow)
VirtualClock frozenAt(Instant frozenAt) (5)
VirtualClock frozenAt(java.time.@NonNull LocalDate frozenAt)
VirtualClock frozenAt(java.time.@NonNull LocalDateTime frozenAt)
VirtualClock frozenAt(java.time.@NonNull OffsetDateTime frozenAt)
VirtualClock frozenAt(java.time.@NonNull ZonedDateTime frozenAt)
VirtualClock frozenAt(java.util.@NonNull Date frozenAt)
VirtualClock frozenTestClock() (6)
ZoneId localTimeZone() (7)
long nowAsEpochMilli() (8)
LocalDate nowAsLocalDate(ZoneId zoneId) (9)
LocalDate nowAsLocalDate() (10)
LocalDateTime nowAsLocalDateTime(ZoneId zoneId) (11)
LocalDateTime nowAsLocalDateTime() (12)
OffsetDateTime nowAsOffsetDateTime(ZoneId zoneId) (13)
OffsetDateTime nowAsOffsetDateTime() (14)
java.util.Date nowAsJavaUtilDate() (15)
java.sql.Timestamp nowAsJavaSqlTimestamp() (16)
XMLGregorianCalendar nowAsXmlGregorianCalendar() (17)
}
| 1 | nowAsInstant()
Returns the (virtual) time as an Instant . |
| 2 | system()
Returns the system’s default ticking clock. |
| 3 | nowAt(Instant)
Returns a ticking clock set to virtual time Instant virtualNow |
| 4 | nowAt(java_time_LocalDate)
Returns a ticking clock set to virtual time. |
| 5 | frozenAt(Instant)
Always returns the time Instant as given by frozenAt |
| 6 | frozenTestClock()
Always returns the time Instant 2003/8/17 21:30:25 (UTC) |
| 7 | localTimeZone()
Used to interpret local time. |
| 8 | nowAsEpochMilli()
Returns the (virtual) time as the number of milliseconds since the epoch start. |
| 9 | nowAsLocalDate(ZoneId)
Returns the (virtual) time as LocalDate , using the ZoneId timezone. |
| 10 | nowAsLocalDate()
Returns the (virtual) time as LocalDate , using the ZoneId#systemDefault() system default timezone. |
| 11 | nowAsLocalDateTime(ZoneId)
Returns the (virtual) time as LocalDateTime , using the ZoneId timezone. |
| 12 | nowAsLocalDateTime()
Returns the (virtual) time as LocalDateTime , using the ZoneId#systemDefault() system default timezone. |
| 13 | nowAsOffsetDateTime(ZoneId)
Returns the (virtual) time as OffsetDateTime , using the ZoneId timezone. |
| 14 | nowAsOffsetDateTime()
Returns the (virtual) time as OffsetDateTime , using the ZoneId#systemDefault() system default timezone. |
| 15 | nowAsJavaUtilDate()
Returns the (virtual)time as java.util.Date . |
| 16 | nowAsJavaSqlTimestamp()
Returns the (virtual) time as java.sql.Timestamp . |
| 17 | nowAsXmlGregorianCalendar()
Returns the (virtual) time as XMLGregorianCalendar . |
Members
nowAsLocalDate()
Returns the (virtual) time as LocalDate , using the ZoneId#systemDefault() system default timezone.
nowAsLocalDateTime()
Returns the (virtual) time as LocalDateTime , using the ZoneId#systemDefault() system default timezone.
nowAsOffsetDateTime(ZoneId)
Returns the (virtual) time as OffsetDateTime , using the ZoneId timezone.