Time¶
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¶
Properties:
var provider: TimeProvider = SystemTimeProvider
Changing the 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.
Member functions:
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 System.currentTimeMillis().
object StaticTimeProvider : TimeProvider¶
Provides a TimeProvider which has a static value which can be changed by the user.
Properties:
var time: Long = 0L
The time property will be returned every time some code calls StaticTimeProvider.now(). No synchronization is done
on this property.