Class OffsetTimePattern
Represents a pattern for parsing and formatting OffsetTime values.
Since 2.3.x
Availability net45, netstandard1.3
Inheritance
Object
OffsetTimePattern
Implements
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 OffsetTimePattern : IPattern<OffsetTime>
Properties
ExtendedIso
Gets an invariant offset time pattern based on ISO-8601 (down to the nanosecond), including offset from UTC.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public static OffsetTimePattern ExtendedIso { get; }
Property Value
Type | Description |
---|---|
OffsetTimePattern | An invariant offset time pattern based on ISO-8601 (down to the nanosecond), including offset from UTC. (The value returned is never null.) |
Remarks
This corresponds to a custom pattern of "HH':'mm':'ss;FFFFFFFFFo<G>".
This will round-trip all values, and is available as the "o" standard pattern.
GeneralIso
Gets an invariant offset time pattern based on ISO-8601 (down to the second), including offset from UTC.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public static OffsetTimePattern GeneralIso { get; }
Property Value
Type | Description |
---|---|
OffsetTimePattern | An invariant offset time pattern based on ISO-8601 (down to the second), including offset from UTC. (The value returned is never null.) |
Remarks
This corresponds to a custom pattern of "HH':'mm':'sso<G>". It is available as the "G"
standard pattern (even though it is invariant).
PatternText
Gets the pattern text for this pattern, as supplied on creation.
Since 2.3.x
Availability net45, netstandard1.3
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.) |
Rfc3339
Gets an invariant offset time pattern based on RFC 3339 (down to the nanosecond), including offset from UTC
as hours and minutes only.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public static OffsetTimePattern Rfc3339 { get; }
Property Value
Type | Description |
---|---|
OffsetTimePattern | An invariant offset time pattern based on RFC 3339 (down to the nanosecond), including offset from UTC as hours and minutes only. (The value returned is never null.) |
Remarks
The minutes part of the offset is always included, but any sub-minute component
of the offset is lost. An offset of zero is formatted as 'Z', but all of 'Z', '+00:00' and '-00:00' are parsed
the same way. The RFC 3339 meaning of '-00:00' is not supported by Noda Time.
Note that parsing is case-sensitive (so 'T' and 'Z' must be upper case).
This pattern corresponds to a custom pattern of
"HH':'mm':'ss;FFFFFFFFFo<Z+HH:mm>".
TemplateValue
Gets the value used as a template for parsing: any field values unspecified
in the pattern are taken from the template.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public OffsetTime TemplateValue { get; }
Property Value
Type | Description |
---|---|
OffsetTime | The value used as a template for parsing. |
Methods
AppendFormat(OffsetTime, StringBuilder)
Formats the given value as text according to the rules of this pattern,
appending to the given System.Text.StringBuilder.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public StringBuilder AppendFormat(OffsetTime value, StringBuilder builder)
Parameters
Type | Name | Description |
---|---|---|
OffsetTime | 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
Type | Condition |
---|---|
ArgumentNullException | builder is null. |
Create(String, CultureInfo, OffsetTime)
Creates a pattern for the given pattern text, culture, and template value.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public static OffsetTimePattern Create(string patternText, CultureInfo cultureInfo, OffsetTime templateValue)
Parameters
Type | Name | Description |
---|---|---|
String | patternText | Pattern text to create the pattern for |
CultureInfo | cultureInfo | The culture to use in the pattern |
OffsetTime | templateValue | Template value to use for unspecified fields |
Returns
Type | Description |
---|---|
OffsetTimePattern | A pattern for parsing and formatting local times. (The value returned is never null.) |
Remarks
See the user guide for the available pattern text options.
Exceptions
Type | Condition |
---|---|
InvalidPatternException | The pattern text was invalid. |
ArgumentNullException | patternText or cultureInfo is null |
CreateWithCurrentCulture(String)
Creates a pattern for the given pattern text in the current culture, using the default
template value of midnight January 1st 2000 at an offset of 0.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public static OffsetTimePattern CreateWithCurrentCulture(string patternText)
Parameters
Type | Name | Description |
---|---|---|
String | patternText | Pattern text to create the pattern for |
Returns
Type | Description |
---|---|
OffsetTimePattern | A pattern for parsing and formatting local times. (The value returned is never null.) |
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. |
ArgumentNullException | patternText is null. |
CreateWithInvariantCulture(String)
Creates a pattern for the given pattern text in the invariant culture, using the default
template value of midnight January 1st 2000 at an offset of 0.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public static OffsetTimePattern CreateWithInvariantCulture(string patternText)
Parameters
Type | Name | Description |
---|---|---|
String | patternText | Pattern text to create the pattern for |
Returns
Type | Description |
---|---|
OffsetTimePattern | A pattern for parsing and formatting local times. (The value returned is never null.) |
Remarks
See the user guide for the available pattern text options.
Exceptions
Type | Condition |
---|---|
InvalidPatternException | The pattern text was invalid. |
ArgumentNullException | patternText is null. |
Format(OffsetTime)
Formats the given zoned time as text according to the rules of this pattern.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public string Format(OffsetTime value)
Parameters
Type | Name | Description |
---|---|---|
OffsetTime | value | The zoned time to format. |
Returns
Type | Description |
---|---|
String | The zoned time 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.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public ParseResult<OffsetTime> Parse(string text)
Parameters
Type | Name | Description |
---|---|---|
String | text | The text value to parse. |
Returns
Type | Description |
---|---|
ParseResult<OffsetTime> | The result of parsing, which may be successful or unsuccessful. (The value returned is never null.) |
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 2.3.x
Availability net45, netstandard1.3
Declaration
public OffsetTimePattern WithCulture(CultureInfo cultureInfo)
Parameters
Type | Name | Description |
---|---|---|
CultureInfo | cultureInfo | The culture to use in the new pattern. |
Returns
Type | Description |
---|---|
OffsetTimePattern | A new pattern with the given culture. (The value returned is never null.) |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | cultureInfo is null. |
WithPatternText(String)
Creates a pattern for the same original localization information as this pattern, but with the specified
pattern text.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public OffsetTimePattern WithPatternText(string patternText)
Parameters
Type | Name | Description |
---|---|---|
String | patternText | The pattern text to use in the new pattern. |
Returns
Type | Description |
---|---|
OffsetTimePattern | A new pattern with the given pattern text. (The value returned is never null.) |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | patternText is null. |
WithTemplateValue(OffsetTime)
Creates a pattern for the same original pattern text and culture as this pattern, but with
the specified template value.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public OffsetTimePattern WithTemplateValue(OffsetTime newTemplateValue)
Parameters
Type | Name | Description |
---|---|---|
OffsetTime | newTemplateValue | The template value to use in the new pattern. |
Returns
Type | Description |
---|---|
OffsetTimePattern | A new pattern with the given template value. (The value returned is never null.) |