Class OffsetPattern
Represents a pattern for parsing and formatting Offset values.
Since 1.4.x
Availability net35-Client, PCL
Inheritance
Object
OffsetPattern
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 OffsetPattern : IPattern<Offset>
Fields
GeneralInvariantPattern
The "general" offset pattern (e.g. +HH, +HH:mm, +HH:mm:ss, +HH:mm:ss.fff) for the invariant culture.
Since 1.4.x
Availability net35-Client, PCL
Declaration
public static readonly OffsetPattern GeneralInvariantPattern
Field Value
Type | Description |
---|---|
OffsetPattern |
GeneralInvariantPatternWithZ
The "general" offset pattern (e.g. +HH, +HH:mm, +HH:mm:ss, +HH:mm:ss.fff) for the invariant culture,
but producing (and allowing) Z as a value for a zero offset.
Since 1.4.x
Availability net35-Client, PCL
Declaration
public static readonly OffsetPattern GeneralInvariantPatternWithZ
Field Value
Type | Description |
---|---|
OffsetPattern |
Properties
PatternText
Returns the pattern text for this pattern, as supplied on creation.
Since 1.4.x
Availability net35-Client, PCL
Declaration
public string PatternText { get; }
Property Value
Type | Description |
---|---|
String |
Methods
Create(String, CultureInfo)
Creates a pattern for the given pattern text and culture.
Since 1.4.x
Availability net35-Client, PCL
Declaration
public static OffsetPattern 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 |
---|---|
OffsetPattern | A pattern for parsing and formatting offsets. |
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.4.x
Availability net35-Client, PCL
Declaration
public static OffsetPattern CreateWithCurrentCulture(string patternText)
Parameters
Type | Name | Description |
---|---|---|
String | patternText | Pattern text to create the pattern for |
Returns
Type | Description |
---|---|
OffsetPattern | A pattern for parsing and formatting offsets. |
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.4.x
Availability net35-Client, PCL
Declaration
public static OffsetPattern CreateWithInvariantCulture(string patternText)
Parameters
Type | Name | Description |
---|---|---|
String | patternText | Pattern text to create the pattern for |
Returns
Type | Description |
---|---|
OffsetPattern | A pattern for parsing and formatting offsets. |
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. |
Format(Offset)
Formats the given offset as text according to the rules of this pattern.
Since 1.4.x
Availability net35-Client, PCL
Declaration
public string Format(Offset value)
Parameters
Type | Name | Description |
---|---|---|
Offset | value | The offset to format. |
Returns
Type | Description |
---|---|
String | The offset formatted according to this pattern. |
Parse(String)
Parses the given text value according to the rules of this pattern.
Since 1.4.x
Availability net35-Client, PCL
Declaration
public ParseResult<Offset> Parse(string text)
Parameters
Type | Name | Description |
---|---|---|
String | text | The text value to parse. |
Returns
Type | Description |
---|---|
ParseResult<Offset> | 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.4.x
Availability net35-Client, PCL
Declaration
public OffsetPattern WithCulture(CultureInfo cultureInfo)
Parameters
Type | Name | Description |
---|---|---|
CultureInfo | cultureInfo | The culture to use in the new pattern. |
Returns
Type | Description |
---|---|
OffsetPattern | A new pattern with the given culture. |