Class OffsetPattern
Represents a pattern for parsing and formatting
Offset values.
Inheritance
OffsetPattern
Assembly: NodaTime.dll
Syntax
public sealed class OffsetPattern : IPattern<Offset>
Properties
GeneralInvariant
The "general" offset pattern (e.g. +HH, +HH:mm, +HH:mm:ss, +HH:mm:ss.fff) for the invariant culture.
Declaration
public static OffsetPattern GeneralInvariant { get; }
Property Value
Type |
Description |
OffsetPattern |
The "general" offset pattern for the invariant culture. (The value returned is never null.) |
GeneralInvariantWithZ
The "general" offset pattern (e.g. +HH, +HH:mm, +HH:mm:ss, +HH:mm:ss.fff) for the invariant culture,
but producing (and allowing) Z as a value for a zero offset.
Declaration
public static OffsetPattern GeneralInvariantWithZ { get; }
Property Value
Type |
Description |
OffsetPattern |
The "general" offset pattern for the invariant culture but producing (and allowing) Z as a value for a zero offset. (The value returned is never null.) |
PatternText
Gets the pattern text for this pattern, as supplied on creation.
Declaration
public string PatternText { get; }
Property Value
Type |
Description |
String |
The pattern text for this pattern, as supplied on creation. (The value returned is never null.) |
Methods
AppendFormat(Offset, StringBuilder)
Formats the given value as text according to the rules of this pattern,
appending to the given
StringBuilder.
Declaration
public StringBuilder AppendFormat(Offset value, StringBuilder builder)
Parameters
Type |
Name |
Description |
Offset |
value |
The value to format. |
StringBuilder |
builder |
The StringBuilder to append to. |
Returns
Type |
Description |
StringBuilder |
The builder passed in as builder . (The value returned is never null.) |
Exceptions
Create(String, CultureInfo)
Creates a pattern for the given pattern text and culture.
Declaration
public static OffsetPattern 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 |
OffsetPattern |
A pattern for parsing and formatting offsets. (The value returned is never null.) |
Exceptions
CreateWithCurrentCulture(String)
Creates a pattern for the given pattern text in the current thread's current culture.
Declaration
public static OffsetPattern CreateWithCurrentCulture(string patternText)
Parameters
Type |
Name |
Description |
String |
patternText |
Pattern text to create the pattern for |
Returns
Type |
Description |
OffsetPattern |
A pattern for parsing and formatting offsets. (The value returned is never null.) |
Exceptions
CreateWithInvariantCulture(String)
Creates a pattern for the given pattern text in the invariant culture.
Declaration
public static OffsetPattern CreateWithInvariantCulture(string patternText)
Parameters
Type |
Name |
Description |
String |
patternText |
Pattern text to create the pattern for |
Returns
Type |
Description |
OffsetPattern |
A pattern for parsing and formatting offsets. (The value returned is never null.) |
Exceptions
Format(Offset)
Formats the given offset as text according to the rules of this pattern.
Declaration
public string Format(Offset value)
Parameters
Type |
Name |
Description |
Offset |
value |
The offset to format. |
Returns
Type |
Description |
String |
The offset formatted according to this pattern. (The value returned is never null.) |
Parse(String)
Parses the given text value according to the rules of this pattern.
Declaration
public ParseResult<Offset> Parse(string text)
Parameters
Type |
Name |
Description |
String |
text |
The text value to parse. |
Returns
Type |
Description |
ParseResult<Offset> |
The result of parsing, which may be successful or unsuccessful. (The value returned is never null.) |
WithCulture(CultureInfo)
Creates a pattern for the same original pattern text as this pattern, but with the specified
culture.
Declaration
public OffsetPattern WithCulture(CultureInfo cultureInfo)
Parameters
Type |
Name |
Description |
CultureInfo |
cultureInfo |
The culture to use in the new pattern. |
Returns
Type |
Description |
OffsetPattern |
A new pattern with the given culture. (The value returned is never null.) |
Exceptions
Implements