Class InstantPattern
Represents a pattern for parsing and formatting
Instant values.
Inheritance
InstantPattern
Assembly: NodaTime.dll
Syntax
public sealed class InstantPattern : IPattern<Instant>
Properties
ExtendedIsoPattern
Returns an invariant instant pattern which is ISO-8601 compatible, providing up to 7 decimal places
of sub-second accuracy. (These digits are omitted when unnecessary.)
This corresponds to the text pattern "yyyy'-'MM'-'dd'T'HH':'mm':'ss;FFFFFFF'Z'".
Declaration
public static InstantPattern ExtendedIsoPattern { get; }
Property Value
GeneralPattern
Returns the general pattern, which always uses an invariant culture. The general pattern represents
an instant as a UTC date/time in ISO-8601 style "yyyy-MM-ddTHH:mm:ss'Z'".
Declaration
public static InstantPattern GeneralPattern { get; }
Property Value
PatternText
Returns the pattern text for this pattern, as supplied on creation.
Declaration
public string PatternText { get; }
Property Value
Methods
Create(String, CultureInfo)
Creates a pattern for the given pattern text and culture.
Declaration
public static InstantPattern Create(string patternText, CultureInfo cultureInfo)
Parameters
Type |
Name |
Description |
String |
patternText |
Pattern text to create the pattern for |
CultureInfo |
cultureInfo |
The culture to use in the pattern |
Returns
Type |
Description |
InstantPattern |
A pattern for parsing and formatting instants. |
Exceptions
CreateNumericPattern(CultureInfo, Boolean)
Creates a "numeric" pattern for the given culture. The numeric format gives the
number of ticks in decimal format, with or without thousands separators.
Declaration
public static InstantPattern CreateNumericPattern(CultureInfo cultureInfo, bool includeThousandsSeparators)
Parameters
Type |
Name |
Description |
CultureInfo |
cultureInfo |
The culture to use in the pattern |
Boolean |
includeThousandsSeparators |
True to include thousands separators when parsing or formatting; false to omit them. |
Returns
Type |
Description |
InstantPattern |
A numeric pattern for the configuration |
CreateWithCurrentCulture(String)
Creates a pattern for the given pattern text in the current thread's current culture.
Declaration
public static InstantPattern CreateWithCurrentCulture(string patternText)
Parameters
Type |
Name |
Description |
String |
patternText |
Pattern text to create the pattern for |
Returns
Type |
Description |
InstantPattern |
A pattern for parsing and formatting instants. |
Exceptions
CreateWithInvariantCulture(String)
Creates a pattern for the given pattern text in the invariant culture, using the default
min/max labels.
Declaration
public static InstantPattern CreateWithInvariantCulture(string patternText)
Parameters
Type |
Name |
Description |
String |
patternText |
Pattern text to create the pattern for |
Returns
Type |
Description |
InstantPattern |
A pattern for parsing and formatting instants. |
Exceptions
Format(Instant)
Formats the given instant as text according to the rules of this pattern.
Declaration
public string Format(Instant value)
Parameters
Type |
Name |
Description |
Instant |
value |
The instant to format. |
Returns
Type |
Description |
String |
The instant formatted according to this pattern. |
Parse(String)
Parses the given text value according to the rules of this pattern.
Declaration
public ParseResult<Instant> Parse(string text)
Parameters
Type |
Name |
Description |
String |
text |
The text value to parse. |
Returns
Type |
Description |
ParseResult<Instant> |
The result of parsing, which may be successful or unsuccessful. |
WithCulture(CultureInfo)
Creates a pattern for the same original pattern text as this pattern, but with the specified
culture.
Declaration
public InstantPattern WithCulture(CultureInfo cultureInfo)
Parameters
Type |
Name |
Description |
CultureInfo |
cultureInfo |
The culture to use in the new pattern. |
Returns
WithMinMaxLabels(String, String)
Creates a new pattern for the same original pattern text and culture as this pattern, but
with the given min/max labels.
Declaration
public InstantPattern WithMinMaxLabels(string minLabel, string maxLabel)
Parameters
Type |
Name |
Description |
String |
minLabel |
Text to use for MinValue. Must be non-empty, and not the same as maxLabel . |
String |
maxLabel |
Text to use for MaxValue. Must be non-empty, and not the same as minLabel |
Returns
Type |
Description |
InstantPattern |
A new pattern with the given min/max labels. |
Exceptions
Implements