Class TimeFormat
Utility class for parsing and formatting dates and times in ISO-compatible format.
public class TimeFormat
- Inheritance
-
TimeFormat
- Inherited Members
Properties
Default
Gets TimeFormat instance that corresponds to default timezone.
public static TimeFormat Default { get; }
Property Value
- TimeFormat
The time format.
GMT
Gets TimeFormat instance that corresponds to GMT timezone.
public static TimeFormat GMT { get; }
Property Value
- TimeFormat
The time format.
Methods
AsFullIso()
Returns TimeFormat instance that produces full ISO8610 string of "yyyy-MM-dd'T'HH:mm:ss.SSSX".
public TimeFormat AsFullIso()
Returns
- TimeFormat
The time format.
Format(long)
Converts value into string according to the format like yyyyMMdd-HHmmss
.
When WithMillis() was used to acquire this TimeFormat instance,
the milliseconds are also included as .sss
.
When value == 0 this method returns string "0".
public string Format(long value)
Parameters
value
longThe milliseconds since January 1, 1970, 00:00:00 GMT.
Returns
- string
The string representation of data and time.
Parse(string)
Reads Date from String. This method is designed to understand ISO 8601 formatted date and time.
public DateTimeOffset Parse(string value)
Parameters
value
stringThe string value to parse.
Returns
- DateTimeOffset
The date parsed from value.
WithMillis()
Returns TimeFormat instance that also includes milliseconds into string when using Format(long) format method.
public TimeFormat WithMillis()
Returns
- TimeFormat
The time format.