Struct Timestamp
Encapsulates a Kafka timestamp and its type.
Inherited Members
Namespace: Confluent.Kafka
Assembly: cs.temp.dll.dll
Syntax
public struct Timestamp
Constructors
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 to create Timestamp from. |
TimestampType | type | The type of 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 |
---|---|
DateTime |
Properties
Type
Gets the timestamp type.
Declaration
public TimestampType Type { get; }
Property Value
Type | Description |
---|---|
TimestampType |
UnixTimestampMs
Get the Unix millisecond timestamp.
Declaration
public long UnixTimestampMs { get; }
Property Value
Type | Description |
---|---|
System.Int64 |
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 |
---|---|
System.Int64 | The milliseconds unix timestamp corresponding to |
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 |
---|---|
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. |