com.groupdocs.search.options

Class DateFormat



  • public class DateFormat
    extends Object

    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
     
    • Constructor Detail

      • DateFormat

        public DateFormat(String cultureName,
                  DateFormatElement[] formatElements)

        Initializes a new instance of the DateFormat class.

        Parameters:
        cultureName - The culture name.
        formatElements - The format elements.
      • DateFormat

        public DateFormat(DateFormatElement[] formatElements,
                  String dateSeparator)

        Initializes a new instance of the DateFormat class.

        Parameters:
        formatElements - The format elements.
        dateSeparator - The date separator.
    • Method Detail

      • getDateSeparator

        public final String getDateSeparator()

        Gets the date separator.

        Returns:
        The date separator.
      • toString

        public String toString()

        Returns a String that represents the current DateFormat.

        Overrides:
        toString in class Object
        Returns:
        A String that represents the current DateFormat.
      • hasDays

        protected static boolean hasDays(DateFormat dateFormat)
      • getFormatted

        protected static String getFormatted(DateFormat format,
                          com.aspose.ms.System.DateTime date)
      • getParts

        protected static String[] getParts(DateFormat format,
                        com.aspose.ms.System.DateTime date)
      • getByteCount

        protected static int getByteCount(DateFormat format)