Class OffsetDateTimePattern
Represents a pattern for parsing and formatting OffsetDateTime values.
Since 1.2.x
Availability net35-Client, PCL
Inheritance
Object
OffsetDateTimePattern
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 OffsetDateTimePattern : IPattern<OffsetDateTime>
Properties
ExtendedIsoPattern
Returns an invariant offset date/time pattern based on ISO-8601 (down to the tick), including offset from UTC.
The calendar system is not parsed or formatted as part of this pattern. It corresponds to a custom pattern of
"yyyy'-'MM'-'dd'T'HH':'mm':'ss;FFFFFFFo<G>". This will round-trip any values
in the ISO calendar, and is available as the "o" standard pattern.
Since 1.2.x
Availability net35-Client, PCL
Declaration
public static OffsetDateTimePattern ExtendedIsoPattern { get; }
Property Value
Type | Description |
---|---|
OffsetDateTimePattern |
FullRoundtripPattern
Returns an invariant offset date/time pattern based on ISO-8601 (down to the tick)
including offset from UTC and calendar ID. It corresponds to a custom pattern of
"yyyy'-'MM'-'dd'T'HH':'mm':'ss;FFFFFFFo<G> '('c')'". This will round-trip any value in any calendar,
and is available as the "r" standard pattern.
Since 1.2.x
Availability net35-Client, PCL
Declaration
public static OffsetDateTimePattern FullRoundtripPattern { get; }
Property Value
Type | Description |
---|---|
OffsetDateTimePattern |
GeneralIsoPattern
Returns an invariant offset date/time pattern based on ISO-8601 (down to the second), including offset from UTC.
The calendar system is not parsed or formatted as part of this pattern. It corresponds to a custom pattern of
"yyyy'-'MM'-'dd'T'HH':'mm':'sso<G>". This pattern is available as the "G"
standard pattern (even though it is invariant).
Since 1.2.x
Availability net35-Client, PCL
Declaration
public static OffsetDateTimePattern GeneralIsoPattern { get; }
Property Value
Type | Description |
---|---|
OffsetDateTimePattern |
PatternText
Returns the pattern text for this pattern, as supplied on creation.
Since 1.2.x
Availability net35-Client, PCL
Declaration
public string PatternText { get; }
Property Value
Type | Description |
---|---|
String |
TemplateValue
Returns the value used as a template for parsing: any field values unspecified
in the pattern are taken from the template.
Since 1.2.x
Availability net35-Client, PCL
Declaration
public OffsetDateTime TemplateValue { get; }
Property Value
Type | Description |
---|---|
OffsetDateTime |
Methods
Create(String, CultureInfo, OffsetDateTime)
Creates a pattern for the given pattern text, culture, and template value.
Since 1.2.x
Availability net35-Client, PCL
Declaration
public static OffsetDateTimePattern Create(string patternText, CultureInfo cultureInfo, OffsetDateTime templateValue)
Parameters
Type | Name | Description |
---|---|---|
String | patternText | Pattern text to create the pattern for |
CultureInfo | cultureInfo | The culture to use in the pattern |
OffsetDateTime | templateValue | Template value to use for unspecified fields |
Returns
Type | Description |
---|---|
OffsetDateTimePattern | A pattern for parsing and formatting local date/times. |
Remarks
See the user guide for the available pattern text options.
Exceptions
Type | Condition |
---|---|
InvalidPatternException | The pattern text was invalid. |
Format(OffsetDateTime)
Formats the given zoned date/time as text according to the rules of this pattern.
Since 1.2.x
Availability net35-Client, PCL
Declaration
public string Format(OffsetDateTime value)
Parameters
Type | Name | Description |
---|---|---|
OffsetDateTime | value | The zoned date/time to format. |
Returns
Type | Description |
---|---|
String | The zoned date/time formatted according to this pattern. |
Parse(String)
Parses the given text value according to the rules of this pattern.
Since 1.2.x
Availability net35-Client, PCL
Declaration
public ParseResult<OffsetDateTime> Parse(string text)
Parameters
Type | Name | Description |
---|---|---|
String | text | The text value to parse. |
Returns
Type | Description |
---|---|
ParseResult<OffsetDateTime> | 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.2.x
Availability net35-Client, PCL
Declaration
public OffsetDateTimePattern WithCulture(CultureInfo cultureInfo)
Parameters
Type | Name | Description |
---|---|---|
CultureInfo | cultureInfo | The culture to use in the new pattern. |
Returns
Type | Description |
---|---|
OffsetDateTimePattern | A new pattern with the given culture. |
WithPatternText(String)
Creates a pattern for the same original localization information as this pattern, but with the specified
pattern text.
Since 1.2.x
Availability net35-Client, PCL
Declaration
public OffsetDateTimePattern WithPatternText(string newPatternText)
Parameters
Type | Name | Description |
---|---|---|
String | newPatternText | The pattern text to use in the new pattern. |
Returns
Type | Description |
---|---|
OffsetDateTimePattern | A new pattern with the given pattern text. |
WithTemplateValue(OffsetDateTime)
Creates a pattern for the same original pattern text and culture as this pattern, but with
the specified template value.
Since 1.2.x
Availability net35-Client, PCL
Declaration
public OffsetDateTimePattern WithTemplateValue(OffsetDateTime newTemplateValue)
Parameters
Type | Name | Description |
---|---|---|
OffsetDateTime | newTemplateValue | The template value to use in the new pattern. |
Returns
Type | Description |
---|---|
OffsetDateTimePattern | A new pattern with the given template value. |