Class AnnualDatePattern
Represents a pattern for parsing and formatting AnnualDate values.
Since 2.3.x
Availability net45, netstandard1.3, netstandard2.0
Inheritance
Object
AnnualDatePattern
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 AnnualDatePattern : IPattern<AnnualDate>
Properties
Iso
Gets an invariant annual date pattern which is compatible with the month/day part of ISO-8601.
This corresponds to the text pattern "MM'-'dd".
Since 2.3.x
Availability net45, netstandard1.3, netstandard2.0
Declaration
public static AnnualDatePattern Iso { get; }
Property Value
Type | Description |
---|---|
AnnualDatePattern | An invariant annual date pattern which is compatible with the month/day part of ISO-8601. (The value returned is never null.) |
PatternText
Gets the pattern text for this pattern, as supplied on creation.
Since 2.3.x
Availability net45, netstandard1.3, netstandard2.0
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.) |
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, netstandard2.0
Declaration
public AnnualDate TemplateValue { get; }
Property Value
Type | Description |
---|---|
AnnualDate | The value used as a template for parsing. |
Methods
AppendFormat(AnnualDate, 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, netstandard2.0
Declaration
public StringBuilder AppendFormat(AnnualDate value, StringBuilder builder)
Parameters
Type | Name | Description |
---|---|---|
AnnualDate | 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)
Creates a pattern for the given pattern text and culture, with a template value of 2000-01-01.
Since 2.3.x
Availability net45, netstandard1.3, netstandard2.0
Declaration
public static AnnualDatePattern 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 |
---|---|
AnnualDatePattern | A pattern for parsing and formatting annual dates. (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 |
Create(String, CultureInfo, AnnualDate)
Creates a pattern for the given pattern text, culture, and template value.
Since 2.3.x
Availability net45, netstandard1.3, netstandard2.0
Declaration
public static AnnualDatePattern Create(string patternText, CultureInfo cultureInfo, AnnualDate templateValue)
Parameters
Type | Name | Description |
---|---|---|
String | patternText | Pattern text to create the pattern for |
CultureInfo | cultureInfo | The culture to use in the pattern |
AnnualDate | templateValue | Template value to use for unspecified fields |
Returns
Type | Description |
---|---|
AnnualDatePattern | A pattern for parsing and formatting annual dates. (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 thread's current culture.
Since 2.3.x
Availability net45, netstandard1.3, netstandard2.0
Declaration
public static AnnualDatePattern CreateWithCurrentCulture(string patternText)
Parameters
Type | Name | Description |
---|---|---|
String | patternText | Pattern text to create the pattern for |
Returns
Type | Description |
---|---|
AnnualDatePattern | A pattern for parsing and formatting annual dates. (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.
Since 2.3.x
Availability net45, netstandard1.3, netstandard2.0
Declaration
public static AnnualDatePattern CreateWithInvariantCulture(string patternText)
Parameters
Type | Name | Description |
---|---|---|
String | patternText | Pattern text to create the pattern for |
Returns
Type | Description |
---|---|
AnnualDatePattern | A pattern for parsing and formatting annual dates. (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. |
Format(AnnualDate)
Formats the given annual date as text according to the rules of this pattern.
Since 2.3.x
Availability net45, netstandard1.3, netstandard2.0
Declaration
public string Format(AnnualDate value)
Parameters
Type | Name | Description |
---|---|---|
AnnualDate | value | The annual date to format. |
Returns
Type | Description |
---|---|
String | The annual date 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, netstandard2.0
Declaration
public ParseResult<AnnualDate> Parse(string text)
Parameters
Type | Name | Description |
---|---|---|
String | text | The text value to parse. |
Returns
Type | Description |
---|---|
ParseResult<AnnualDate> | 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, netstandard2.0
Declaration
public AnnualDatePattern WithCulture(CultureInfo cultureInfo)
Parameters
Type | Name | Description |
---|---|---|
CultureInfo | cultureInfo | The culture to use in the new pattern. |
Returns
Type | Description |
---|---|
AnnualDatePattern | A new pattern with the given culture. (The value returned is never null.) |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | cultureInfo is null. |
WithTemplateValue(AnnualDate)
Creates a pattern like this one, but with the specified template value.
Since 2.3.x
Availability net45, netstandard1.3, netstandard2.0
Declaration
public AnnualDatePattern WithTemplateValue(AnnualDate newTemplateValue)
Parameters
Type | Name | Description |
---|---|---|
AnnualDate | newTemplateValue | The template value for the new pattern, used to fill in unspecified fields. |
Returns
Type | Description |
---|---|
AnnualDatePattern | A new pattern with the given template value. (The value returned is never null.) |