Noda Time
Show / Hide Table of Contents

Class OffsetDateTimePattern

Represents a pattern for parsing and formatting OffsetDateTime values.
Since 1.2.x
Availability net35-Client, PCL
Inheritance
Object
OffsetDateTimePattern
Implements
IPattern<OffsetDateTime>
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

ExtendedIso

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.4.x
Availability net35-Client, PCL
Declaration
public static OffsetDateTimePattern ExtendedIso { get; }
Property Value
Type Description
OffsetDateTimePattern

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
[Obsolete("Use ExtendedIso for compatibility with 2.0")]
public static OffsetDateTimePattern ExtendedIsoPattern { get; }
Property Value
Type Description
OffsetDateTimePattern

FullRoundtrip

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.4.x
Availability net35-Client, PCL
Declaration
public static OffsetDateTimePattern FullRoundtrip { 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
[Obsolete("Use FullRoundtrip for compatibility with 2.0")]
public static OffsetDateTimePattern FullRoundtripPattern { get; }
Property Value
Type Description
OffsetDateTimePattern

GeneralIso

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.4.x
Availability net35-Client, PCL
Declaration
public static OffsetDateTimePattern GeneralIso { 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
[Obsolete("Use GeneralIso for compatibility with 2.0")]
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

Rfc3339

Returns an invariant offset date/time pattern based on RFC 3339 (down to the tick), including offset from UTC as hours and minutes only. 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). 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<Z+HH:mm>".
Since 1.4.x
Availability net35-Client, PCL
Declaration
public static OffsetDateTimePattern Rfc3339 { get; }
Property Value
Type Description
OffsetDateTimePattern

Rfc3339Pattern

Returns an invariant offset date/time pattern based on RFC 3339 (down to the tick), including offset from UTC as hours and minutes only. 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). 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<Z+HH:mm>".
Since 1.3.x
Availability net35-Client, PCL
Declaration
[Obsolete("Use Rfc3339 for compatibility with 2.0")]
public static OffsetDateTimePattern Rfc3339Pattern { get; }
Property Value
Type Description
OffsetDateTimePattern

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.

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 1.3.x
Availability net35-Client, PCL
Declaration
public static OffsetDateTimePattern CreateWithCurrentCulture(string patternText)
Parameters
Type Name Description
String patternText Pattern text to create the pattern for
Returns
Type Description
OffsetDateTimePattern A pattern for parsing and formatting local date/times.
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.

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 1.3.x
Availability net35-Client, PCL
Declaration
public static OffsetDateTimePattern CreateWithInvariantCulture(string patternText)
Parameters
Type Name Description
String patternText Pattern text to create the pattern for
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.

Implements

IPattern<T>
In this article
Back to top Generated by DocFX