Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class NodaTime.​Text.​InstantPattern

Assembly: NodaTime

Inheritance: object → InstantPattern

Implemented Interfaces

Represents a pattern for parsing and formatting <see cref="T:NodaTime.Instant" /> values.

Properties

public static InstantPattern
General
Gets the general pattern, which always uses an invariant culture. The general pattern represents an instant as a UTC date/time in ISO-8601 style "uuuu-MM-ddTHH:mm:ss'Z'".
public static InstantPattern
ExtendedIso
Gets an invariant instant pattern which is ISO-8601 compatible, providing up to 9 decimal places of sub-second accuracy. (These digits are omitted when unnecessary.) This corresponds to the text pattern "uuuu'-'MM'-'dd'T'HH':'mm':'ss;FFFFFFFFF'Z'".
public string
PatternText
Gets the pattern text for this pattern, as supplied on creation.
public Instant
TemplateValue
Gets the value used as a template for parsing: any field values unspecified in the pattern are taken from the template.
public int
TwoDigitYearMax
Maximum two-digit-year in the template to treat as the current century. If the value parsed is higher than this, the result is adjusted to the previous century. This value defaults to 30. To create a pattern with a different value, use <see cref="M:NodaTime.Text.InstantPattern.WithTwoDigitYearMax(System.Int32)" /> .

Methods

public ParseResult<​Instant>
Parse​(string text)
Parses the given text value according to the rules of this pattern.
Returns The result of parsing, which may be successful or unsuccessful.
text The text value to parse.
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.
public string
Format​(Instant value)
Formats the given instant as text according to the rules of this pattern.
Returns The instant formatted according to this pattern.
value The instant to format.
AppendFormat​(Instant value, System.​Text.​StringBuilder builder)
Formats the given value as text according to the rules of this pattern, appending to the given <see cref="T:System.Text.StringBuilder" /> .
Returns The builder passed in as <paramref name="builder" /> .
value The value to format.
builder The <c>StringBuilder</c> to append to.
public static InstantPattern
Create​(string patternText, System.​Globalization.​CultureInfo cultureInfo)
Creates a pattern for the given pattern text and culture.
Returns A pattern for parsing and formatting instants.
patternText Pattern text to create the pattern for
cultureInfo The culture to use in the pattern
Remarks See the user guide for the available pattern text options.
public static InstantPattern
CreateWithCurrentCulture​(string patternText)
Creates a pattern for the given pattern text in the current thread's current culture.
Returns A pattern for parsing and formatting instants.
patternText Pattern text to create the pattern for
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.
public static InstantPattern
CreateWithInvariantCulture​(string patternText)
Creates a pattern for the given pattern text in the invariant culture.
Returns A pattern for parsing and formatting instants.
patternText Pattern text to create the pattern for
Remarks See the user guide for the available pattern text options.
WithCulture​(System.​Globalization.​CultureInfo cultureInfo)
Creates a pattern for the same original pattern text as this pattern, but with the specified culture.
Returns A new pattern with the given culture.
cultureInfo The culture to use in the new pattern.
WithTemplateValue​(Instant newTemplateValue)
Creates a pattern like this one, but with the specified template value.
Returns A new pattern with the given template value.
newTemplateValue The template value for the new pattern, used to fill in unspecified fields.
WithTwoDigitYearMax​(int twoDigitYearMax)
Creates a pattern like this one, but with a different <see cref="P:NodaTime.Text.InstantPattern.TwoDigitYearMax" /> value.
Returns A new pattern with the specified maximum two-digit-year.
twoDigitYearMax The value to use for <see cref="P:NodaTime.Text.InstantPattern.TwoDigitYearMax" /> in the new pattern, in the range 0-99 inclusive.
public bool
Equals​(object obj)
Inherited from object
protected void
Finalize​()
Inherited from object
public int
GetHashCode​()
Inherited from object
GetType​()
Inherited from object
protected object
MemberwiseClone​()
Inherited from object
public string
ToString​()
Inherited from object