UCloud provides a
Time object which should be used for all actions which require a timestamp. The timestamps used in
UCloud are always returned as time expressed as milliseconds since the time 00:00:00 UTC on January 1, 1970.
Example: Retrieving the current time
val timestamp = Time.now()
object Time : TimeProvider¶
var provider: TimeProvider = SystemTimeProvider
provider allows you to mock the time. This is extremely useful for testing time-releated code. You
should never change the
provider in UCloud production code.
fun TimeProvider.now(): Long
Returns the current time expressed as milliseconds since the time 00:00:00 UTC on January 1, 1970. See also System.currentTimeMillis.
object SystemTimeProvider : TimeProvider¶
Provides the default time provider. This delegates to
object StaticTimeProvider : TimeProvider¶
TimeProvider which has a static value which can be changed by the user.
var time: Long = 0L
time property will be returned every time some code calls
StaticTimeProvider.now(). No synchronization is done
on this property.