DateFormat

Inheritance: java.lang.Object

public class DateFormat

Represents a date format.

Learn more

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.getDateFormats().clear(); // Removing default date formats
 DateFormatElement[] elements = new DateFormatElement[] {
     DateFormatElement.getMonthTwoDigits(),
     DateFormatElement.getDateSeparator(),
     DateFormatElement.getDayOfMonthTwoDigits(),
     DateFormatElement.getDateSeparator(),
     DateFormatElement.getYearFourDigits(),
 };
 // Creating a date format pattern 'MM/dd/yyyy'
 com.groupdocs.search.DateFormat dateFormat = new com.groupdocs.search.DateFormat(elements, "/");
 options.getDateFormats().addItem(dateFormat);
 SearchResult result = index.search(query, options); // Search in index
 

Constructors

Constructor Description
DateFormat(String cultureName, DateFormatElement[] formatElements) Initializes a new instance of the DateFormat class.
DateFormat(DateFormatElement[] formatElements, String dateSeparator) Initializes a new instance of the DateFormat class.

Methods

Method Description
getDateSeparator() Gets the date separator.
toString() Returns a String that represents the current DateFormat .
getCore()

DateFormat(String cultureName, DateFormatElement[] formatElements)

public DateFormat(String cultureName, DateFormatElement[] formatElements)

Initializes a new instance of the DateFormat class.

Parameters:

Parameter Type Description
cultureName java.lang.String The culture name.
formatElements DateFormatElement[] The format elements.

DateFormat(DateFormatElement[] formatElements, String dateSeparator)

public DateFormat(DateFormatElement[] formatElements, String dateSeparator)

Initializes a new instance of the DateFormat class.

Parameters:

Parameter Type Description
formatElements DateFormatElement[] The format elements.
dateSeparator java.lang.String The date separator.

getDateSeparator()

public String getDateSeparator()

Gets the date separator.

Returns: java.lang.String - The date separator.

toString()

public String toString()

Returns a String that represents the current DateFormat .

Returns: java.lang.String - A String that represents the current DateFormat .

getCore()

public Object getCore()

Returns: java.lang.Object