Class InstantPattern
Represents a pattern for parsing and formatting Instant values.
Since 1.0.x
Availability net35-Client, PCL
Inheritance
Object
InstantPattern
Inherited Members
Object.ToString()
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Namespace: NodaTime.Text
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'".
Since 1.0.x
Availability net35-Client, PCL
Declaration
public static InstantPattern ExtendedIsoPattern { get; }
Property Value
Type | Description |
---|---|
InstantPattern |
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'".
Since 1.0.x
Availability net35-Client, PCL
Declaration
public static InstantPattern GeneralPattern { get; }
Property Value
Type | Description |
---|---|
InstantPattern |
PatternText
Returns the pattern text for this pattern, as supplied on creation.
Since 1.0.x
Availability net35-Client, PCL
Declaration
public string PatternText { get; }
Property Value
Type | Description |
---|---|
String |
Methods
Create(String, CultureInfo)
Creates a pattern for the given pattern text and culture.
Since 1.0.x
Availability net35-Client, PCL
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. |
Remarks
See the user guide for the available pattern text options.
Exceptions
Type | Condition |
---|---|
InvalidPatternException | The pattern text was invalid. |
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.
Since 1.0.x
Availability net35-Client, PCL
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.
Since 1.0.x
Availability net35-Client, PCL
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. |
Remarks
See the user guide for the available pattern text options. Note that the current culture
is captured at the time this method is called - it is not captured at the point of parsing
or formatting values.
Exceptions
Type | Condition |
---|---|
InvalidPatternException | The pattern text was invalid. |
CreateWithInvariantCulture(String)
Creates a pattern for the given pattern text in the invariant culture, using the default
min/max labels.
Since 1.0.x
Availability net35-Client, PCL
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. |
Remarks
See the user guide for the available pattern text options.
Exceptions
Type | Condition |
---|---|
InvalidPatternException | The pattern text was invalid. |
Format(Instant)
Formats the given instant as text according to the rules of this pattern.
Since 1.0.x
Availability net35-Client, PCL
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.
Since 1.0.x
Availability net35-Client, PCL
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. |
Remarks
This method never throws an exception (barring a bug in Noda Time itself). Even errors such as
the argument being null are wrapped in a parse result.
WithCulture(CultureInfo)
Creates a pattern for the same original pattern text as this pattern, but with the specified
culture.
Since 1.0.x
Availability net35-Client, PCL
Declaration
public InstantPattern WithCulture(CultureInfo cultureInfo)
Parameters
Type | Name | Description |
---|---|---|
CultureInfo | cultureInfo | The culture to use in the new pattern. |
Returns
Type | Description |
---|---|
InstantPattern | A new pattern with the given culture. |
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.
Since 1.2.x
Availability net35-Client, PCL
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
Type | Condition |
---|---|
ArgumentException |