Noda Time
Show / Hide Table of Contents

Class LocalDateTimePattern

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

Properties

BclRoundtrip

Returns an invariant local date/time pattern which is ISO-8601 compatible, providing up to 7 decimal places of sub-second accuracy which are always present (including trailing zeroes). This is compatible with the BCL round-trip formatting of System.DateTime values with a kind of "unspecified". This corresponds to the text pattern "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffff".
Since 1.4.x
Availability net35-Client, PCL
Declaration
public static LocalDateTimePattern BclRoundtrip { get; }
Property Value
Type Description
LocalDateTimePattern

BclRoundtripPattern

Returns an invariant local date/time pattern which is ISO-8601 compatible, providing up to 7 decimal places of sub-second accuracy which are always present (including trailing zeroes). This is compatible with the BCL round-trip formatting of System.DateTime values with a kind of "unspecified". This corresponds to the text pattern "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffff".
Since 1.2.x
Availability net35-Client, PCL
Declaration
[Obsolete("Use BclRoundtrip for compatibility with 2.0")]
public static LocalDateTimePattern BclRoundtripPattern { get; }
Property Value
Type Description
LocalDateTimePattern

ExtendedIso

Returns an invariant local date/time pattern which is ISO-8601 compatible, providing up to 7 decimal places of sub-second accuracy. (These digits are omitted when unnecessary.) This corresponds to the text pattern "yyyy'-'MM'-'dd'T'HH':'mm':'ss;FFFFFFF".
Since 1.4.x
Availability net35-Client, PCL
Declaration
public static LocalDateTimePattern ExtendedIso { get; }
Property Value
Type Description
LocalDateTimePattern

ExtendedIsoPattern

Returns an invariant local date/time pattern which is ISO-8601 compatible, providing up to 7 decimal places of sub-second accuracy. (These digits are omitted when unnecessary.) This corresponds to the text pattern "yyyy'-'MM'-'dd'T'HH':'mm':'ss;FFFFFFF".
Since 1.0.x
Availability net35-Client, PCL
Declaration
[Obsolete("Use ExtendedIso for compatibility with 2.0")]
public static LocalDateTimePattern ExtendedIsoPattern { get; }
Property Value
Type Description
LocalDateTimePattern

FullRoundtrip

Returns an invariant local date/time pattern which round trips values including the calendar system. This corresponds to the text pattern "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffff '('c')'".
Since 1.4.x
Availability net35-Client, PCL
Declaration
public static LocalDateTimePattern FullRoundtrip { get; }
Property Value
Type Description
LocalDateTimePattern

FullRoundtripPattern

Returns an invariant local date/time pattern which round trips values including the calendar system. This corresponds to the text pattern "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffff '('c')'".
Since 1.2.x
Availability net35-Client, PCL
Declaration
[Obsolete("Use FullRoundtrip for compatibility with 2.0")]
public static LocalDateTimePattern FullRoundtripPattern { get; }
Property Value
Type Description
LocalDateTimePattern

GeneralIso

Returns an invariant local date/time pattern which is ISO-8601 compatible, down to the second. This corresponds to the text pattern "yyyy'-'MM'-'dd'T'HH':'mm':'ss", and is also used as the "sortable" standard pattern.
Since 1.4.x
Availability net35-Client, PCL
Declaration
public static LocalDateTimePattern GeneralIso { get; }
Property Value
Type Description
LocalDateTimePattern

GeneralIsoPattern

Returns an invariant local date/time pattern which is ISO-8601 compatible, down to the second. This corresponds to the text pattern "yyyy'-'MM'-'dd'T'HH':'mm':'ss", and is also used as the "sortable" standard pattern.
Since 1.2.x
Availability net35-Client, PCL
Declaration
[Obsolete("Use GeneralIso for compatibility with 2.0")]
public static LocalDateTimePattern GeneralIsoPattern { get; }
Property Value
Type Description
LocalDateTimePattern

PatternText

Returns the pattern text for this pattern, as supplied on creation.
Since 1.0.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.0.x
Availability net35-Client, PCL
Declaration
public LocalDateTime TemplateValue { get; }
Property Value
Type Description
LocalDateTime

Methods

Create(String, CultureInfo)

Creates a pattern for the given pattern text and culture, with a template value of midnight on 2000-01-01.
Since 1.0.x
Availability net35-Client, PCL
Declaration
public static LocalDateTimePattern 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
LocalDateTimePattern 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.

Create(String, CultureInfo, LocalDateTime)

Creates a pattern for the given pattern text, culture, and template value.
Since 1.0.x
Availability net35-Client, PCL
Declaration
public static LocalDateTimePattern Create(string patternText, CultureInfo cultureInfo, LocalDateTime templateValue)
Parameters
Type Name Description
String patternText Pattern text to create the pattern for
CultureInfo cultureInfo The culture to use in the pattern
LocalDateTime templateValue Template value to use for unspecified fields
Returns
Type Description
LocalDateTimePattern 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 thread's current culture.
Since 1.0.x
Availability net35-Client, PCL
Declaration
public static LocalDateTimePattern CreateWithCurrentCulture(string patternText)
Parameters
Type Name Description
String patternText Pattern text to create the pattern for
Returns
Type Description
LocalDateTimePattern 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.
Since 1.0.x
Availability net35-Client, PCL
Declaration
public static LocalDateTimePattern CreateWithInvariantCulture(string patternText)
Parameters
Type Name Description
String patternText Pattern text to create the pattern for
Returns
Type Description
LocalDateTimePattern 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(LocalDateTime)

Formats the given local date/time as text according to the rules of this pattern.
Since 1.0.x
Availability net35-Client, PCL
Declaration
public string Format(LocalDateTime value)
Parameters
Type Name Description
LocalDateTime value The local date/time to format.
Returns
Type Description
String The local date/time formatted according to this pattern.

Parse(String)

Parses the given text value according to the rules of this pattern.
Since 1.0.x
Availability net35-Client, PCL
Declaration
public ParseResult<LocalDateTime> Parse(string text)
Parameters
Type Name Description
String text The text value to parse.
Returns
Type Description
ParseResult<LocalDateTime> 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.0.x
Availability net35-Client, PCL
Declaration
public LocalDateTimePattern WithCulture(CultureInfo cultureInfo)
Parameters
Type Name Description
CultureInfo cultureInfo The culture to use in the new pattern.
Returns
Type Description
LocalDateTimePattern A new pattern with the given culture.

WithTemplateValue(LocalDateTime)

Creates a pattern like this one, but with the specified template value.
Since 1.0.x
Availability net35-Client, PCL
Declaration
public LocalDateTimePattern WithTemplateValue(LocalDateTime newTemplateValue)
Parameters
Type Name Description
LocalDateTime newTemplateValue The template value for the new pattern, used to fill in unspecified fields.
Returns
Type Description
LocalDateTimePattern A new pattern with the given template value.

Implements

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