Class SystemClock
Singleton implementation of IClock which reads the current system time.
It is recommended that for anything other than throwaway code, this is only referenced
in a single place in your code: where you provide a value to inject into the rest of
your application, which should only depend on the interface.
Since 1.0.x
Availability net6.0, net8.0, netstandard2.0
Implements
Inherited Members
Namespace: NodaTime
Assembly: NodaTime.dll
Syntax
public sealed class SystemClock : IClock
Properties
Instance
The singleton instance of SystemClock.
Since 1.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public static SystemClock Instance { get; }
Property Value
Type | Description |
---|---|
SystemClock | The singleton instance of SystemClock. |
Methods
GetCurrentInstant()
Gets the current time as an Instant.
Since 2.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public Instant GetCurrentInstant()
Returns
Type | Description |
---|---|
Instant | The current time in ticks as an Instant. |