Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
class NodaTime.​Text.​LocalTimePattern
Assembly: NodaTime
Inheritance: object → LocalTimePattern
Implemented Interfaces
Represents a pattern for parsing and formatting <see cref="T:NodaTime.LocalTime" /> values.
Properties
public static
LocalTimePattern
ExtendedIso
Gets an invariant local time pattern which is ISO-8601 compatible, providing up to 9 decimal places.
(These digits are omitted when unnecessary.)
This corresponds to the text pattern "HH':'mm':'ss;FFFFFFFFF".
Remarks This pattern corresponds to the 'o' standard pattern.
public static
LocalTimePattern
LongExtendedIso
Gets an invariant local time pattern which is ISO-8601 compatible, providing exactly 9 decimal places.
This corresponds to the text pattern "HH':'mm':'ss;fffffffff".
Remarks This pattern corresponds to the 'O' standard pattern.
public static
LocalTimePattern
GeneralIso
Gets an invariant local time pattern which is ISO-8601 compatible, with precision of just seconds.
This corresponds to the text pattern "HH':'mm':'ss".
public static
LocalTimePattern
HourMinuteIso
Gets an invariant local time pattern which is ISO-8601 compatible, with precision of just minutes.
This corresponds to the text pattern "HH':'mm".
public static
LocalTimePattern
HourIso
Gets an invariant local time pattern which is ISO-8601 compatible, with a precision of just hours.
This corresponds to the text pattern "HH".
Gets an invariant local time pattern which can parse any ISO-8601 compatible value
(in extended format, that is, with separators), regardless of precision.
Valid values include "just hours", "hours and minutes", "hours, minutes and seconds",
and values with fractions of seconds (as far as nanoseconds).
Remarks This is expressed as an <see cref="T:NodaTime.Text.IPattern`1" /> rather than a <see cref="T:NodaTime.Text.LocalTimePattern" /> ,
as it has no single pattern text.
public
string
PatternText
Gets the pattern text for this pattern, as supplied on creation.
public
LocalTime
TemplateValue
Gets the value used as a template for parsing: any field values unspecified
in the pattern are taken from the template.
Methods
public
ParseResult<​LocalTime>
Parse​(string text)
Parses the given text value according to the rules of this pattern.
Returns The result of parsing, which may be successful or unsuccessful.
text
The text value to parse.
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.
public
string
Format​(LocalTime value)
Formats the given local time as text according to the rules of this pattern.
Returns The local time formatted according to this pattern.
value
The local time to format.
AppendFormat​(LocalTime value,
System.​Text.​StringBuilder builder)
Formats the given value as text according to the rules of this pattern,
appending to the given <see cref="T:System.Text.StringBuilder" /> .
Returns The builder passed in as <paramref name="builder" /> .
value
The value to format.
builder
The <c>StringBuilder</c> to append to.
public static
LocalTimePattern
Create​(string patternText,
System.​Globalization.​CultureInfo cultureInfo,
LocalTime templateValue)
Creates a pattern for the given pattern text, culture, and template value.
Returns A pattern for parsing and formatting local times.
patternText
Pattern text to create the pattern for
cultureInfo
The culture to use in the pattern
templateValue
Template value to use for unspecified fields
Remarks
See the user guide for the available pattern text options.
public static
LocalTimePattern
Create​(string patternText,
System.​Globalization.​CultureInfo cultureInfo)
Creates a pattern for the given pattern text and culture, with a template value of midnight.
Returns A pattern for parsing and formatting local times.
patternText
Pattern text to create the pattern for
cultureInfo
The culture to use in the pattern
Remarks
See the user guide for the available pattern text options.
public static
LocalTimePattern
CreateWithCurrentCulture​(string patternText)
Creates a pattern for the given pattern text in the current thread's current culture.
Returns A pattern for parsing and formatting local times.
patternText
Pattern text to create the pattern for
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.
public static
LocalTimePattern
CreateWithInvariantCulture​(string patternText)
Creates a pattern for the given pattern text in the invariant culture.
Returns A pattern for parsing and formatting local times.
patternText
Pattern text to create the pattern for
Remarks
See the user guide for the available pattern text options.
public
LocalTimePattern
WithCulture​(System.​Globalization.​CultureInfo cultureInfo)
Creates a pattern for the same original pattern text as this pattern, but with the specified
culture.
Returns A new pattern with the given culture.
cultureInfo
The culture to use in the new pattern.
public
LocalTimePattern
WithTemplateValue​(LocalTime newTemplateValue)
Creates a pattern like this one, but with the specified template value.
Returns A new pattern with the given template value.
newTemplateValue
The template value for the new pattern, used to fill in unspecified fields.
public
bool
Equals​(object obj)
Inherited from object
protected
void
Finalize​()
Inherited from object
public
int
GetHashCode​()
Inherited from object
protected
object
MemberwiseClone​()
Inherited from object
public
string
ToString​()
Inherited from object