public class DateFormat extends Object
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
Constructor and Description |
---|
DateFormat(DateFormatElement[] formatElements,
String dateSeparator)
Initializes a new instance of the
DateFormat class. |
DateFormat(String cultureName,
DateFormatElement[] formatElements)
Initializes a new instance of the
DateFormat class. |
Modifier and Type | Method and Description |
---|---|
protected static DateFormat |
create(ArrayReader reader) |
protected static int |
getByteCount(DateFormat format) |
String |
getDateSeparator()
Gets the date separator.
|
protected static String |
getFormatted(DateFormat format,
com.aspose.ms.System.DateTime date) |
protected static String[] |
getParts(DateFormat format,
com.aspose.ms.System.DateTime date) |
protected static boolean |
hasDays(DateFormat dateFormat) |
protected static void |
toByteArray(DateFormat format,
ArrayWriter writer) |
String |
toString()
Returns a String that represents the current
DateFormat . |
public DateFormat(String cultureName, DateFormatElement[] formatElements)
DateFormat
class.cultureName
- The culture name.formatElements
- The format elements.public DateFormat(DateFormatElement[] formatElements, String dateSeparator)
DateFormat
class.formatElements
- The format elements.dateSeparator
- The date separator.public final String getDateSeparator()
public String toString()
DateFormat
.protected static boolean hasDays(DateFormat dateFormat)
protected static String getFormatted(DateFormat format, com.aspose.ms.System.DateTime date)
protected static String[] getParts(DateFormat format, com.aspose.ms.System.DateTime date)
protected static int getByteCount(DateFormat format)
protected static void toByteArray(DateFormat format, ArrayWriter writer)
protected static DateFormat create(ArrayReader reader)