DateFormat

DateFormat class

Represents a date format.

public class DateFormat

Constructors

Name Description
DateFormat(DateFormatElement[], string) Initializes a new instance of the DateFormat class.
DateFormat(string, DateFormatElement[]) Initializes a new instance of the DateFormat class.

Properties

Name Description
DateSeparator { get; } Gets the date separator.

Methods

Name Description
override ToString() Returns a String that represents the current DateFormat.

Remarks

Learn more

Examples

The example demonstrates a typical usage of the class.

string indexFolder = @"c:\MyIndex\";
string documentsFolder = @"c:\MyDocuments\";
string query = "daterange(2017-01-01 ~~ 2019-12-31)";

Index index = new Index(indexFolder); // Creating an index in the specified folder
index.Add(documentsFolder); // Indexing documents from the specified folder

SearchOptions options = new SearchOptions();
options.DateFormats.Clear(); // Removing default date formats
DateFormatElement[] elements = new DateFormatElement[]
{
    DateFormatElement.MonthTwoDigits,
    DateFormatElement.DateSeparator,
    DateFormatElement.DayOfMonthTwoDigits,
    DateFormatElement.DateSeparator,
    DateFormatElement.YearFourDigits,
};
// Creating a date format pattern 'MM/dd/yyyy'
DateFormat dateFormat = new DateFormat(elements, "/");
options.DateFormats.Add(dateFormat);

SearchResult result = index.Search(query, options); // Search in index

See Also