Noda Time
Show / Hide Table of Contents

Class LocalDatePattern

Represents a pattern for parsing and formatting LocalDate values.
Since 1.0.x
Availability net45, netstandard1.3
Inheritance
Object
LocalDatePattern
Implements
IPattern<LocalDate>
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 LocalDatePattern : IPattern<LocalDate>

Properties

Iso

Gets an invariant local date pattern which is ISO-8601 compatible. This corresponds to the text pattern "uuuu'-'MM'-'dd".
Since 1.4.x
Availability net45, netstandard1.3
Declaration
public static LocalDatePattern Iso { get; }
Property Value
Type Description
LocalDatePattern An invariant local date pattern which is ISO-8601 compatible.

PatternText

Gets the pattern text for this pattern, as supplied on creation.
Since 1.0.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.

TemplateValue

Gets the value used as a template for parsing: any field values unspecified in the pattern are taken from the template.
Since 1.0.x
Availability net45, netstandard1.3
Declaration
public LocalDate TemplateValue { get; }
Property Value
Type Description
LocalDate The value used as a template for parsing.

Methods

AppendFormat(LocalDate, StringBuilder)

Formats the given value as text according to the rules of this pattern, appending to the given System.Text.StringBuilder.
Since 2.0.x
Availability net45, netstandard1.3
Declaration
public StringBuilder AppendFormat(LocalDate value, StringBuilder builder)
Parameters
Type Name Description
LocalDate value The value to format.
StringBuilder builder The StringBuilder to append to.
Returns
Type Description
StringBuilder The builder passed in as builder.
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 1.0.x
Availability net45, netstandard1.3
Declaration
public static LocalDatePattern 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
LocalDatePattern A pattern for parsing and formatting local dates.
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, LocalDate)

Creates a pattern for the given pattern text, culture, and template value.
Since 1.0.x
Availability net45, netstandard1.3
Declaration
public static LocalDatePattern Create(string patternText, CultureInfo cultureInfo, LocalDate templateValue)
Parameters
Type Name Description
String patternText Pattern text to create the pattern for
CultureInfo cultureInfo The culture to use in the pattern
LocalDate templateValue Template value to use for unspecified fields
Returns
Type Description
LocalDatePattern A pattern for parsing and formatting local dates.
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 1.0.x
Availability net45, netstandard1.3
Declaration
public static LocalDatePattern CreateWithCurrentCulture(string patternText)
Parameters
Type Name Description
String patternText Pattern text to create the pattern for
Returns
Type Description
LocalDatePattern A pattern for parsing and formatting local dates.
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 1.0.x
Availability net45, netstandard1.3
Declaration
public static LocalDatePattern CreateWithInvariantCulture(string patternText)
Parameters
Type Name Description
String patternText Pattern text to create the pattern for
Returns
Type Description
LocalDatePattern A pattern for parsing and formatting local dates.
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(LocalDate)

Formats the given local date as text according to the rules of this pattern.
Since 1.0.x
Availability net45, netstandard1.3
Declaration
public string Format(LocalDate value)
Parameters
Type Name Description
LocalDate value The local date to format.
Returns
Type Description
String The local date formatted according to this pattern.

Parse(String)

Parses the given text value according to the rules of this pattern.
Since 1.0.x
Availability net45, netstandard1.3
Declaration
public ParseResult<LocalDate> Parse(string text)
Parameters
Type Name Description
String text The text value to parse.
Returns
Type Description
ParseResult<LocalDate> 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.

WithCalendar(CalendarSystem)

Creates a pattern like this one, but with the template value modified to use the specified calendar system.
Since 2.0.x
Availability net45, netstandard1.3
Declaration
public LocalDatePattern WithCalendar(CalendarSystem calendar)
Parameters
Type Name Description
CalendarSystem calendar The calendar system to convert the template value into.
Returns
Type Description
LocalDatePattern A new pattern with a template value in the specified calendar system.
Remarks

Care should be taken in two (relatively rare) scenarios. Although the default template value is supported by all Noda Time calendar systems, if a pattern is created with a different template value and then this method is called with a calendar system which doesn't support that date, an exception will be thrown. Additionally, if the pattern only specifies some date fields, it's possible that the new template value will not be suitable for all values.

Exceptions
Type Condition
ArgumentNullException calendar is null.

WithCulture(CultureInfo)

Creates a pattern for the same original pattern text as this pattern, but with the specified culture.
Since 1.0.x
Availability net45, netstandard1.3
Declaration
public LocalDatePattern WithCulture(CultureInfo cultureInfo)
Parameters
Type Name Description
CultureInfo cultureInfo The culture to use in the new pattern.
Returns
Type Description
LocalDatePattern A new pattern with the given culture.
Exceptions
Type Condition
ArgumentNullException cultureInfo is null.

WithTemplateValue(LocalDate)

Creates a pattern like this one, but with the specified template value.
Since 1.0.x
Availability net45, netstandard1.3
Declaration
public LocalDatePattern WithTemplateValue(LocalDate newTemplateValue)
Parameters
Type Name Description
LocalDate newTemplateValue The template value for the new pattern, used to fill in unspecified fields.
Returns
Type Description
LocalDatePattern A new pattern with the given template value.

Implements

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