Struct Timestamp
Encapsulates a Kafka timestamp and its type.
Implements
Inherited Members
Namespace: Confluent.Kafka
Assembly: Confluent.Kafka.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 |
---|---|---|
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 |
---|---|---|
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 |
---|---|---|
DateTimeOffset | dateTimeOffset | The DateTimeOffset value corresponding to the timestamp. |
Timestamp(long, TimestampType)
Initializes a new instance of the Timestamp structure.
Declaration
public Timestamp(long unixTimestampMs, TimestampType type)
Parameters
Type | Name | Description |
---|---|---|
long | 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 |
---|---|
DateTime |
Properties
Default
A read-only field representing an unspecified timestamp.
Declaration
public static 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 |
---|---|
long |
UtcDateTime
Gets the UTC DateTime corresponding to the UnixTimestampMs.
Declaration
public DateTime UtcDateTime { get; }
Property Value
Type | Description |
---|---|
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 |
---|---|---|
DateTime | dateTime | The DateTime value to convert. |
Returns
Type | Description |
---|---|
long | 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 |
---|---|
bool | 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 |
---|---|---|
object | obj | Determines whether this instance and a specified object, which must also be a Timestamp object, have the same value. |
Returns
Type | Description |
---|---|
bool | 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 |
---|---|
int | A 32-bit signed integer hash code. |
Overrides
UnixTimestampMsToDateTime(long)
Convert a milliseconds unix timestamp to a DateTime value.
Declaration
public static DateTime UnixTimestampMsToDateTime(long unixMillisecondsTimestamp)
Parameters
Type | Name | Description |
---|---|---|
long | unixMillisecondsTimestamp | The milliseconds unix timestamp to convert. |
Returns
Type | Description |
---|---|
DateTime | The DateTime value associated with |
Operators
operator ==(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 |
---|---|
bool | true if the value of a is the same as the value of b; otherwise, false. |
operator !=(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 |
---|---|
bool | true if the value of a is different from the value of b; otherwise, false. |