Class NumberDateFormat
This Lucene.Net.Util.NumberFormat parses System.Int64 into date strings and vice-versa. It
uses the given dateFormat
and System.Globalization.CultureInfo to parse and format dates, but before, it
converts System.Int64 to System.DateTime objects or vice-versa.
The System.Int64 value the dates are parsed into and out of is specified by changing NumericRepresentation. The default value is UNIX_TIME_MILLISECONDS, which is the number of milliseconds since January 1, 1970 0:00:00 UTC, also known as the "epoch".
Inheritance
Inherited Members
Namespace: Lucene.Net.QueryParsers.Flexible.Standard.Config
Assembly: Lucene.Net.QueryParser.dll
Syntax
public class NumberDateFormat : NumberFormat
Constructors
| Improve this Doc View SourceNumberDateFormat(DateFormat, DateFormat, IFormatProvider)
Constructs a NumberDateFormat object using the provided dateStyle
,
timeStyle
, and provider
.
Declaration
public NumberDateFormat(DateFormat dateStyle, DateFormat timeStyle, IFormatProvider provider)
Parameters
Type | Name | Description |
---|---|---|
DateFormat | dateStyle | The date formatting style. For example, SHORT for "M/d/yyyy" in the en-US culture. |
DateFormat | timeStyle | The time formatting style. For example, SHORT for "h:mm tt" in the en-US culture. |
System.IFormatProvider | provider | An object that supplies culture-specific formatting information. |
NumberDateFormat(DateFormat, IFormatProvider)
Constructs a NumberDateFormat object using the provided dateStyle
and provider
.
Declaration
public NumberDateFormat(DateFormat dateStyle, IFormatProvider provider)
Parameters
Type | Name | Description |
---|---|---|
DateFormat | dateStyle | The date formatting style. For example, SHORT for "M/d/yy" in the en-US culture. |
System.IFormatProvider | provider | An object that supplies culture-specific formatting information. |
NumberDateFormat(String, IFormatProvider)
Constructs a NumberDateFormat object using the given dateFormat
and provider
.
Declaration
public NumberDateFormat(string dateFormat, IFormatProvider provider)
Parameters
Type | Name | Description |
---|---|---|
System.String | dateFormat | Date format used to parse and format dates. |
System.IFormatProvider | provider | An object that supplies culture-specific formatting information. |
Properties
| Improve this Doc View SourceNumericRepresentation
The numeric representation to convert the date into when calling Parse(String) or convert the date from when calling Format(Int64) overloads.
Declaration
public NumericRepresentation NumericRepresentation { get; set; }
Property Value
Type | Description |
---|---|
Lucene.Net.Documents.NumericRepresentation |
TimeZone
The time zone to convert dates to when using Format(Int64) or from when using Parse(String).
Declaration
public virtual TimeZoneInfo TimeZone { get; set; }
Property Value
Type | Description |
---|---|
System.TimeZoneInfo |
Methods
| Improve this Doc View SourceFormat(Double)
Declaration
public override string Format(double number)
Parameters
Type | Name | Description |
---|---|---|
System.Double | number |
Returns
Type | Description |
---|---|
System.String |
Overrides
| Improve this Doc View SourceFormat(Int64)
Declaration
public override string Format(long number)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | number |
Returns
Type | Description |
---|---|
System.String |
Overrides
| Improve this Doc View SourceFormat(Object)
Declaration
public override string Format(object number)
Parameters
Type | Name | Description |
---|---|---|
System.Object | number |
Returns
Type | Description |
---|---|
System.String |
Overrides
| Improve this Doc View SourceGetDateFormat()
Returns the .NET date format that will be used to Format the date. Note that parsing the date uses System.DateTime.ParseExact(System.String,System.String,System.IFormatProvider).
Declaration
public string GetDateFormat()
Returns
Type | Description |
---|---|
System.String |
GetDateFormat(DateFormat, DateFormat, IFormatProvider)
Gets a date format string similar to Java's SimpleDateFormat using the specified dateStyle
,
timeStyle
and provider
.
Declaration
public static string GetDateFormat(DateFormat dateStyle, DateFormat timeStyle, IFormatProvider provider)
Parameters
Type | Name | Description |
---|---|---|
DateFormat | dateStyle | The date formatting style. For example, SHORT for "M/d/yyyy" in the en-US culture. |
DateFormat | timeStyle | The time formatting style. For example, SHORT for "h:mm tt" in the en-US culture. |
System.IFormatProvider | provider | An object that supplies culture-specific formatting information. If |
Returns
Type | Description |
---|---|
System.String | A date and time format string with a space separator. |
GetDateFormat(DateFormat, IFormatProvider)
Gets a date format string similar to Java's SimpleDateFormat using the specified dateStyle
and provider
.
Declaration
public static string GetDateFormat(DateFormat dateStyle, IFormatProvider provider)
Parameters
Type | Name | Description |
---|---|---|
DateFormat | dateStyle | The date formatting style. For example, SHORT for "M/d/yyyy" in the en-US culture. |
System.IFormatProvider | provider | An object that supplies culture-specific formatting information. If |
Returns
Type | Description |
---|---|
System.String | A date format string. |
Parse(String)
Declaration
public override Number Parse(string source)
Parameters
Type | Name | Description |
---|---|---|
System.String | source |
Returns
Type | Description |
---|---|
J2N.Numerics.Number |
Overrides
| Improve this Doc View SourceSetDateFormat(String)
Declaration
public void SetDateFormat(string dateFormat)
Parameters
Type | Name | Description |
---|---|---|
System.String | dateFormat |