Class LuceneUtils
- java.lang.Object
-
- com.atlassian.confluence.search.v2.lucene.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.- Since:
- 7.16.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LuceneUtils.Resolution
Specifies the time granularity.
-
Constructor Summary
Constructors Constructor Description LuceneUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
dateToString(Date date)
Converts a Date into a String using the Lucene index format, with a millisecond resolution.static String
dateToString(Date date, LuceneUtils.Resolution resolution)
Converts a Date to a string suitable for indexing.static Date
stringToDate(String s)
Converts a String from the Lucene index format into a Date.
-
-
-
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(java.util.Date)
-
dateToString
public static String dateToString(Date date, LuceneUtils.Resolution resolution)
Converts a Date to a string suitable for indexing.- Parameters:
date
- the date to be convertedresolution
- the desired resolution- Returns:
- a string in format
yyyyMMddHHmmssSSS
or shorter, depending onresolution
; 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.
-
-