Show / Hide Table of Contents

Class DateTimeUtils

Miscellaneuos utility methods for DateTime manipulation.

Inheritance
object
DateTimeUtils
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Tangosol.Util
Assembly: Coherence.dll
Syntax
public abstract class DateTimeUtils

Methods

GetDateTime(long)

Convert the passed in time in milliseconds to a DateTime object.

Declaration
public static DateTime GetDateTime(long timeMillis)
Parameters
Type Name Description
long timeMillis

A timestamp in milliseconds since the 1/1/0001.

Returns
Type Description
DateTime

A corresponding DateTime object for the passed in time in milliseconds.

GetLastSafeTimeMillis()

Returns the last "safe" time as computed by a previous call to the GetSafeTimeMillis method. Note: Since the underlying field is non-volatile, the returned value is only guaranteed to be no less than the last value returned by GetSafeTimeMillis() call on the same thread.

Declaration
public long GetLastSafeTimeMillis()
Returns
Type Description
long

The last "safe" time in milliseconds.

GetSafeTimeMillis()

Returns a "safe" current time in milliseconds.

Declaration
public static long GetSafeTimeMillis()
Returns
Type Description
long

The difference, measured in milliseconds, between the corrected current time and midnight, January 1, 0001.

Remarks

This method guarantees that the time never "goes back". More specifically, when called twice on the same thread, the second call will never return a value that is less then the value returned by the first call. If a system time correction becomes necessary, an attempt will be made to gradually compensate the returned value, so in the long run the value returned by this method is the same as the system time.

GetTimeMillisFromEpochBasedTime(long)

Convert the passed in time in milliseconds from time since the epoch (Jan 1, 1970) to time since 1/1/0001.

Declaration
public static long GetTimeMillisFromEpochBasedTime(long timeMillis)
Parameters
Type Name Description
long timeMillis

A timestamp in milliseconds since the epoch (Jan 1, 1970).

Returns
Type Description
long

The passed in time converted to milliseconds since the 1/1/0001.

GetTimeMillisSinceTheEpoch(long)

Convert the passed in time in milliseconds from time since 1/1/0001 to time since the epoch (Jan 1, 1970).

Declaration
public static long GetTimeMillisSinceTheEpoch(long timeMillis)
Parameters
Type Name Description
long timeMillis

A timestamp in milliseconds since 1/1/0001.

Returns
Type Description
long

The passed in time converted to milliseconds since the epoch (Jan 1, 1970).

IsBeforeTheEpoch(long)

Return whether the passed in time in milliseconds is before the epoch (Jan 1, 1970).

Declaration
public static bool IsBeforeTheEpoch(long timeMillis)
Parameters
Type Name Description
long timeMillis

A timestamp in milliseconds since 1/1/0001.

Returns
Type Description
bool

True if the passed in time in milliseconds is before the epoch (Jan 1, 1970).

In this article
Back to top Copyright © 2000, 2024, Oracle and/or its affiliates.