Class ZonedDateTimePattern
Represents a pattern for parsing and formatting ZonedDateTime values.
Since 1.2.x
Availability net35-Client, PCL
Inheritance
Object
ZonedDateTimePattern
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 ZonedDateTimePattern : IPattern<ZonedDateTime>
Properties
ExtendedFormatOnlyIso
Returns an invariant zoned date/time pattern based on ISO-8601 (down to the tick) including offset from UTC and zone ID.
It corresponds to a custom pattern of "yyyy'-'MM'-'dd'T'HH':'mm':'ss;FFFFFFF z '('o<g>')'" and is available
as the 'F' standard pattern.
Since 1.4.x
Availability net35-Client, PCL
Declaration
public static ZonedDateTimePattern ExtendedFormatOnlyIso { get; }
Property Value
Type | Description |
---|---|
ZonedDateTimePattern |
Remarks
The calendar system is not formatted as part of this pattern, and it cannot be used for parsing as no time zone
provider is included. Call WithZoneProvider(IDateTimeZoneProvider) on the value of this property to obtain a
pattern which can be used for parsing.
ExtendedFormatOnlyIsoPattern
Returns an invariant zoned date/time pattern based on ISO-8601 (down to the tick) including offset from UTC and zone ID.
It corresponds to a custom pattern of "yyyy'-'MM'-'dd'T'HH':'mm':'ss;FFFFFFF z '('o<g>')'" and is available
as the 'F' standard pattern.
Since 1.2.x
Availability net35-Client, PCL
Declaration
[Obsolete("Use ExtendedFormatOnlyIso for compatibility with 2.0")]
public static ZonedDateTimePattern ExtendedFormatOnlyIsoPattern { get; }
Property Value
Type | Description |
---|---|
ZonedDateTimePattern |
Remarks
The calendar system is not formatted as part of this pattern, and it cannot be used for parsing as no time zone
provider is included. Call WithZoneProvider(IDateTimeZoneProvider) on the value of this property to obtain a
pattern which can be used for parsing.
GeneralFormatOnlyIso
Returns an zoned local date/time pattern based on ISO-8601 (down to the second) including offset from UTC and zone ID.
It corresponds to a custom pattern of "yyyy'-'MM'-'dd'T'HH':'mm':'ss z '('o<g>')'" and is available
as the 'G' standard pattern.
Since 1.4.x
Availability net35-Client, PCL
Declaration
public static ZonedDateTimePattern GeneralFormatOnlyIso { get; }
Property Value
Type | Description |
---|---|
ZonedDateTimePattern |
Remarks
The calendar system is not formatted as part of this pattern, and it cannot be used for parsing as no time zone
provider is included. Call WithZoneProvider(IDateTimeZoneProvider) on the value of this property to obtain a
pattern which can be used for parsing.
GeneralFormatOnlyIsoPattern
Returns an zoned local date/time pattern based on ISO-8601 (down to the second) including offset from UTC and zone ID.
It corresponds to a custom pattern of "yyyy'-'MM'-'dd'T'HH':'mm':'ss z '('o<g>')'" and is available
as the 'G' standard pattern.
Since 1.2.x
Availability net35-Client, PCL
Declaration
[Obsolete("Use GeneralFormatOnlyIso for compatibility with 2.0")]
public static ZonedDateTimePattern GeneralFormatOnlyIsoPattern { get; }
Property Value
Type | Description |
---|---|
ZonedDateTimePattern |
Remarks
The calendar system is not formatted as part of this pattern, and it cannot be used for parsing as no time zone
provider is included. Call WithZoneProvider(IDateTimeZoneProvider) on the value of this property to obtain a
pattern which can be used for parsing.
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 |
Resolver
Returns the resolver which is used to map local date/times to zoned date/times,
handling skipped and ambiguous times appropriately (where the offset isn't specified in the pattern).
Since 1.2.x
Availability net35-Client, PCL
Declaration
public ZoneLocalMappingResolver Resolver { get; }
Property Value
Type | Description |
---|---|
ZoneLocalMappingResolver |
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 ZonedDateTime TemplateValue { get; }
Property Value
Type | Description |
---|---|
ZonedDateTime |
ZoneProvider
Returns the provider which is used to look up time zones when parsing a pattern
which contains a time zone identifier. This may be null, in which case the pattern can
only be used for formatting (not parsing).
Since 1.2.x
Availability net35-Client, PCL
Declaration
public IDateTimeZoneProvider ZoneProvider { get; }
Property Value
Type | Description |
---|---|
IDateTimeZoneProvider |
Methods
Create(String, CultureInfo, ZoneLocalMappingResolver, IDateTimeZoneProvider, ZonedDateTime)
Creates a pattern for the given pattern text, culture, resolver, time zone provider, and template value.
Since 1.2.x
Availability net35-Client, PCL
Declaration
public static ZonedDateTimePattern Create(string patternText, CultureInfo cultureInfo, ZoneLocalMappingResolver resolver, IDateTimeZoneProvider zoneProvider, ZonedDateTime templateValue)
Parameters
Type | Name | Description |
---|---|---|
String | patternText | Pattern text to create the pattern for |
CultureInfo | cultureInfo | The culture to use in the pattern |
ZoneLocalMappingResolver | resolver | Resolver to apply when mapping local date/time values into the zone. |
IDateTimeZoneProvider | zoneProvider | Time zone provider, used when parsing text which contains a time zone identifier. |
ZonedDateTime | templateValue | Template value to use for unspecified fields |
Returns
Type | Description |
---|---|
ZonedDateTimePattern | A pattern for parsing and formatting zoned date/times. |
Remarks
See the user guide for the available pattern text options.
If
zoneProvider
is null, the resulting pattern can be used for formatting
but not parsing.
Exceptions
Type | Condition |
---|---|
InvalidPatternException | The pattern text was invalid. |
CreateWithCurrentCulture(String, IDateTimeZoneProvider)
Creates a pattern for the given pattern text and time zone provider, using a strict resolver, the current
culture, and a default template value of midnight January 1st 2000 UTC.
Since 1.3.x
Availability net35-Client, PCL
Declaration
public static ZonedDateTimePattern CreateWithCurrentCulture(string patternText, IDateTimeZoneProvider zoneProvider)
Parameters
Type | Name | Description |
---|---|---|
String | patternText | Pattern text to create the pattern for |
IDateTimeZoneProvider | zoneProvider | Time zone provider, used when parsing text which contains a time zone identifier. |
Returns
Type | Description |
---|---|
ZonedDateTimePattern | A pattern for parsing and formatting zoned date/times. |
Remarks
The resolver is only used if the pattern text doesn't include an offset.
If
zoneProvider
is null, the resulting pattern can be used for formatting
but not parsing. 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.
CreateWithInvariantCulture(String, IDateTimeZoneProvider)
Creates a pattern for the given pattern text and time zone provider, using a strict resolver, the invariant
culture, and a default template value of midnight January 1st 2000 UTC.
Since 1.2.x
Availability net35-Client, PCL
Declaration
public static ZonedDateTimePattern CreateWithInvariantCulture(string patternText, IDateTimeZoneProvider zoneProvider)
Parameters
Type | Name | Description |
---|---|---|
String | patternText | Pattern text to create the pattern for |
IDateTimeZoneProvider | zoneProvider | Time zone provider, used when parsing text which contains a time zone identifier. |
Returns
Type | Description |
---|---|
ZonedDateTimePattern | A pattern for parsing and formatting zoned date/times. |
Remarks
The resolver is only used if the pattern text doesn't include an offset.
If
zoneProvider
is null, the resulting pattern can be used for formatting
but not parsing.
Format(ZonedDateTime)
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(ZonedDateTime value)
Parameters
Type | Name | Description |
---|---|---|
ZonedDateTime | 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<ZonedDateTime> Parse(string text)
Parameters
Type | Name | Description |
---|---|---|
String | text | The text value to parse. |
Returns
Type | Description |
---|---|
ParseResult<ZonedDateTime> | 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 ZonedDateTimePattern WithCulture(CultureInfo cultureInfo)
Parameters
Type | Name | Description |
---|---|---|
CultureInfo | cultureInfo | The culture to use in the new pattern. |
Returns
Type | Description |
---|---|
ZonedDateTimePattern | 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 ZonedDateTimePattern WithPatternText(string newPatternText)
Parameters
Type | Name | Description |
---|---|---|
String | newPatternText | The pattern text to use in the new pattern. |
Returns
Type | Description |
---|---|
ZonedDateTimePattern | A new pattern with the given pattern text. |
WithResolver(ZoneLocalMappingResolver)
Creates a pattern for the same original pattern text as this pattern, but with the specified
resolver.
Since 1.2.x
Availability net35-Client, PCL
Declaration
public ZonedDateTimePattern WithResolver(ZoneLocalMappingResolver newResolver)
Parameters
Type | Name | Description |
---|---|---|
ZoneLocalMappingResolver | newResolver | The new local mapping resolver to use. |
Returns
Type | Description |
---|---|
ZonedDateTimePattern | A new pattern with the given resolver. |
WithTemplateValue(ZonedDateTime)
Creates a pattern like this one, but with the specified template value.
Since 1.2.x
Availability net35-Client, PCL
Declaration
public ZonedDateTimePattern WithTemplateValue(ZonedDateTime newTemplateValue)
Parameters
Type | Name | Description |
---|---|---|
ZonedDateTime | newTemplateValue | The template value for the new pattern, used to fill in unspecified fields. |
Returns
Type | Description |
---|---|
ZonedDateTimePattern | A new pattern with the given template value. |
WithZoneProvider(IDateTimeZoneProvider)
Creates a pattern for the same original pattern text as this pattern, but with the specified
time zone provider.
Since 1.2.x
Availability net35-Client, PCL
Declaration
public ZonedDateTimePattern WithZoneProvider(IDateTimeZoneProvider newZoneProvider)
Parameters
Type | Name | Description |
---|---|---|
IDateTimeZoneProvider | newZoneProvider | The new time zone provider to use. |
Returns
Type | Description |
---|---|
ZonedDateTimePattern | A new pattern with the given time zone provider. |
Remarks
If
newZoneProvider
is null, the resulting pattern can be used for formatting
but not parsing.