I have a TimeUuid
which I need to convert to a DateTime
.
Is there a way to do this in C#?
I am using a CassandraCsharpDriver from DataStax, but it does not have the capability to convert the TimeUuid
to Datetime
, but the opposite is possible.
Example UUID: d91027c5-bd42-11e6-90be-2b4914b28d57
You can use the GetDate()
method of the TimeUuid
structure, that returns the DateTimeOffset
representation of the value.
TimeUuid uuidValue = row.GetValue<TimeUuid>("time");
// TimeUuid structure exposes GetDate() method
DateTimeOffset dateOffset = uuidValue.GetDate();
DateTime dateTime = dateOffset.DateTime;