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.​DurationPattern
Assembly: NodaTime
Inheritance: object → DurationPattern
Implemented Interfaces
Represents a pattern for parsing and formatting <see cref="T:NodaTime.Duration" /> values.
Properties
public static
DurationPattern
Roundtrip
Gets the general pattern for durations using the invariant culture, with a format string of "-D:hh:mm:ss.FFFFFFFFF".
This pattern round-trips. This corresponds to the "o" standard pattern.
public static
DurationPattern
JsonRoundtrip
Gets a pattern for durations using the invariant culture, with a format string of "-H:mm:ss.FFFFFFFFF".
This pattern round-trips, and is the pattern that NodaTime.Serialization.JsonNet uses by default.
This corresponds to the "j" standard pattern.
public
string
PatternText
Gets the pattern text for this pattern, as supplied on creation.
Methods
public
ParseResult<​Duration>
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​(Duration value)
Formats the given duration as text according to the rules of this pattern.
Returns The duration formatted according to this pattern.
value
The duration to format.
AppendFormat​(Duration 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
DurationPattern
Create​(string patternText,
System.​Globalization.​CultureInfo cultureInfo)
Creates a pattern for the given pattern text and culture.
Returns A pattern for parsing and formatting offsets.
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
DurationPattern
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 offsets.
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
DurationPattern
CreateWithInvariantCulture​(string patternText)
Creates a pattern for the given pattern text in the invariant culture.
Returns A pattern for parsing and formatting offsets.
patternText
Pattern text to create the pattern for
Remarks
See the user guide for the available pattern text options.
public
DurationPattern
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
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