Interface IPattern<T>
Generic interface supporting parsing and formatting. Parsing always results in a
ParseResult<T> which can represent success or failure.
Since 1.0.x
Availability netstandard2.0
Namespace: NodaTime.Text
Assembly: NodaTime.dll
Syntax
public interface IPattern<T>
Type Parameters
Name | Description |
---|---|
T | Type of value to parse or format. |
Remarks
Idiomatic text handling in Noda Time involves creating a pattern once and reusing it multiple
times, rather than specifying the pattern text repeatedly. All patterns are immutable and thread-safe,
and include the culture used for localization purposes.
Methods
AppendFormat(T, StringBuilder)
Formats the given value as text according to the rules of this pattern,
appending to the given System.Text.StringBuilder.
Since 2.0.x
Availability netstandard2.0
Declaration
StringBuilder AppendFormat(T value, StringBuilder builder)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to format. |
StringBuilder | builder | The StringBuilder to append to. |
Returns
Type | Description |
---|---|
StringBuilder | The builder passed in as builder . |
Format(T)
Formats the given value as text according to the rules of this pattern.
Since 1.0.x
Availability netstandard2.0
Declaration
string Format(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to format. |
Returns
Type | Description |
---|---|
String | The value formatted according to this pattern. |
Parse(String)
Parses the given text value according to the rules of this pattern.
Since 1.0.x
Availability netstandard2.0
Declaration
ParseResult<T> Parse(string text)
Parameters
Type | Name | Description |
---|---|---|
String | text | The text value to parse. |
Returns
Type | Description |
---|---|
ParseResult<T> | 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.