Table of Contents

Class DateTimeUtilities

Namespace
Org.BouncyCastle.Utilities.Date
Assembly
BouncyCastle.Cryptography.dll
public static class DateTimeUtilities
Inheritance
DateTimeUtilities
Inherited Members

Fields

MaxUnixMs

public static readonly long MaxUnixMs

Field Value

long

MinUnixMs

public static readonly long MinUnixMs

Field Value

long

UnixEpoch

public static readonly DateTime UnixEpoch

Field Value

DateTime

Methods

CurrentUnixMs()

Return the current number of milliseconds since the Unix epoch (1 Jan., 1970 UTC).

public static long CurrentUnixMs()

Returns

long

DateTimeToUnixMs(DateTime)

Return the number of milliseconds since the Unix epoch (1 Jan., 1970 UTC) for a given DateTime value.

public static long DateTimeToUnixMs(DateTime dateTime)

Parameters

dateTime DateTime

A DateTime value not before the epoch.

Returns

long

Number of whole milliseconds after epoch.

Remarks

The DateTime value will be converted to UTC (using ToUniversalTime() before conversion.

Exceptions

ArgumentOutOfRangeException

'dateTime' is before the epoch.

UnixMsToDateTime(long)

Create a UTC DateTime value from the number of milliseconds since the Unix epoch (1 Jan., 1970 UTC).

public static DateTime UnixMsToDateTime(long unixMs)

Parameters

unixMs long

Number of milliseconds since the epoch.

Returns

DateTime

A UTC DateTime value

Exceptions

ArgumentOutOfRangeException

'unixMs' is before 'MinUnixMs' or after 'MaxUnixMs'.

WithPrecisionCentisecond(DateTime)

public static DateTime WithPrecisionCentisecond(DateTime dateTime)

Parameters

dateTime DateTime

Returns

DateTime

WithPrecisionDecisecond(DateTime)

public static DateTime WithPrecisionDecisecond(DateTime dateTime)

Parameters

dateTime DateTime

Returns

DateTime

WithPrecisionMillisecond(DateTime)

public static DateTime WithPrecisionMillisecond(DateTime dateTime)

Parameters

dateTime DateTime

Returns

DateTime

WithPrecisionSecond(DateTime)

public static DateTime WithPrecisionSecond(DateTime dateTime)

Parameters

dateTime DateTime

Returns

DateTime