Class LuceneUtils

  • public class LuceneUtils
    extends Object
    Utilities for Lucene-related functionality in applications.

    Some logic copied from the DateTools class in Lucene 4.4. Done to maintain Lucene independent assumptions about how dates should be formatted for indexing. This is required as there are many implicit baked in assumptions about date formatting around confluence, we don't want it to be changed in the future.

    • Constructor Detail

      • LuceneUtils

        public LuceneUtils()
    • Method Detail

      • dateToString

        public static String dateToString​(Date date)
        Converts a Date into a String using the Lucene index format, with a millisecond resolution.
        See Also:
      • dateToString

        public static String dateToString​(Date date,
                                          LuceneUtils.Resolution resolution)
        Converts a Date to a string suitable for indexing.
        date - the date to be converted
        resolution - the desired resolution
        a string in format yyyyMMddHHmmssSSS or shorter, depending on resolution; using GMT as timezone
      • stringToDate

        public static Date stringToDate​(String s)
        Converts a String from the Lucene index format into a Date. Attempts conversion using both new and old date formats. If the String is blank or null, returns a new Date object.

        If the string is in the old format, this method will log a warning a limited number of times per application run to recommend that the user upgrades the index format.