Struct Timestamp
Encapsulates a Kafka timestamp and its type.
Implements
Inherited Members
Namespace: Confluent.Kafka
Assembly: cs.temp.dll.dll
Syntax
public struct Timestamp : IEquatable<Timestamp>
Constructors
Timestamp(DateTime)
Initializes a new instance of the Timestamp structure.
Note: dateTime
is first converted
to UTC if it is not already and TimestampType is set
to CreateTime.
Declaration
public Timestamp(DateTime dateTime)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | dateTime | The DateTime value corresponding to the timestamp. |
Timestamp(DateTime, TimestampType)
Initializes a new instance of the Timestamp structure.
Note: dateTime
is first converted to UTC
if it is not already.
Declaration
public Timestamp(DateTime dateTime, TimestampType type)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | dateTime | The DateTime value corresponding to the timestamp. |
TimestampType | type | The type of the timestamp. |
Timestamp(DateTimeOffset)
Initializes a new instance of the Timestamp structure. Note: TimestampType is set to CreateTime.
Declaration
public Timestamp(DateTimeOffset dateTimeOffset)
Parameters
Type | Name | Description |
---|---|---|
System.DateTimeOffset | dateTimeOffset | The DateTimeOffset value corresponding to the timestamp. |
Timestamp(Int64, TimestampType)
Initializes a new instance of the Timestamp structure.
Declaration
public Timestamp(long unixTimestampMs, TimestampType type)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | unixTimestampMs | The unix millisecond timestamp. |
TimestampType | type | The type of the timestamp. |
Fields
UnixTimeEpoch
Unix epoch as a UTC DateTime. Unix time is defined as the number of seconds past this UTC time, excluding leap seconds.
Declaration
public static readonly DateTime UnixTimeEpoch
Field Value
Type | Description |
---|---|
System.DateTime |
Properties
Default
A read-only field representing an unspecified timestamp.
Declaration
public static readonly Timestamp Default { get; }
Property Value
Type | Description |
---|---|
Timestamp |
Type
Gets the timestamp type.
Declaration
public readonly TimestampType Type { get; }
Property Value
Type | Description |
---|---|
TimestampType |
UnixTimestampMs
Get the Unix millisecond timestamp.
Declaration
public readonly long UnixTimestampMs { get; }
Property Value
Type | Description |
---|---|
System.Int64 |
UtcDateTime
Gets the UTC DateTime corresponding to the UnixTimestampMs.
Declaration
public readonly DateTime UtcDateTime { get; }
Property Value
Type | Description |
---|---|
System.DateTime |
Methods
DateTimeToUnixTimestampMs(DateTime)
Convert a DateTime instance to a milliseconds unix timestamp.
Note: dateTime
is first converted to UTC
if it is not already.
Declaration
public static long DateTimeToUnixTimestampMs(DateTime dateTime)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | dateTime | The DateTime value to convert. |
Returns
Type | Description |
---|---|
System.Int64 | The milliseconds unix timestamp corresponding to |
Equals(Timestamp)
Determines whether two Timestamps have the same value.
Declaration
public bool Equals(Timestamp other)
Parameters
Type | Name | Description |
---|---|---|
Timestamp | other | The timestamp to test. |
Returns
Type | Description |
---|---|
System.Boolean | true if other has the same value. false otherwise. |
Equals(Object)
Determines whether two Timestamps have the same value.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | Determines whether this instance and a specified object, which must also be a Timestamp object, have the same value. |
Returns
Type | Description |
---|---|
System.Boolean | true if obj is a Timestamp and its value is the same as this instance; otherwise, false. If obj is null, the method returns false. |
Overrides
GetHashCode()
Returns the hashcode for this Timestamp.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 | A 32-bit signed integer hash code. |
Overrides
UnixTimestampMsToDateTime(Int64)
Convert a milliseconds unix timestamp to a DateTime value.
Declaration
public static DateTime UnixTimestampMsToDateTime(long unixMillisecondsTimestamp)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | unixMillisecondsTimestamp | The milliseconds unix timestamp to convert. |
Returns
Type | Description |
---|---|
System.DateTime | The DateTime value associated with |
Operators
Equality(Timestamp, Timestamp)
Determines whether two specified Timestamps have the same value.
Declaration
public static bool operator ==(Timestamp a, Timestamp b)
Parameters
Type | Name | Description |
---|---|---|
Timestamp | a | The first Timestamp to compare. |
Timestamp | b | The second Timestamp to compare |
Returns
Type | Description |
---|---|
System.Boolean | true if the value of a is the same as the value of b; otherwise, false. |
Inequality(Timestamp, Timestamp)
Determines whether two specified Timestamps have different values.
Declaration
public static bool operator !=(Timestamp a, Timestamp b)
Parameters
Type | Name | Description |
---|---|---|
Timestamp | a | The first Timestamp to compare. |
Timestamp | b | The second Timestamp to compare |
Returns
Type | Description |
---|---|
System.Boolean | true if the value of a is different from the value of b; otherwise, false. |