Package org.hippoecm.repository.util
Class DateTools
java.lang.Object
org.hippoecm.repository.util.DateTools
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Specifies the time granularity. -
Method Summary
Modifier and TypeMethodDescriptionstatic String
createXPathConstraint
(Session session, Calendar calendar) static String
createXPathConstraint
(Session session, Calendar calendar, DateTools.Resolution roundDateBy) static String
dateToString
(Date date, DateTools.Resolution resolution) Converts a Date to a string suitable for indexing.static String
getPropertyForResolution
(String property, DateTools.Resolution resolution) static DateTools.Resolution[]
Deprecated.static Iterable<DateTools.Resolution>
static long
round
(long time, DateTools.Resolution resolution) Limit a date's resolution.static Calendar
roundDate
(long time, DateTools.Resolution resolution) Limit a date's resolution.static Date
stringToDate
(String dateString, DateTools.Resolution resolution) static String
timeToString
(long time, DateTools.Resolution resolution) Converts a millisecond time to a string suitable for indexing.
-
Method Details
-
dateToString
Converts a Date to a string suitable for indexing.- Parameters:
date
- the date to be convertedresolution
- the desired resolution, seeround(long, DateTools.Resolution)
- Returns:
- a string in format
yyyyMMddHHmmssSSS
or shorter, depeding onresolution
; using UTC as timezone
-
timeToString
Converts a millisecond time to a string suitable for indexing.- Parameters:
time
- the date expressed as milliseconds since January 1, 1970, 00:00:00 GMTresolution
- the desired resolution, seeround(long, DateTools.Resolution)
- Returns:
- a string in format
yyyyMMddHHmmssSSS
or shorter,depending onresolution
; using UTC as timezone
-
round
Limit a date's resolution. For example, the date1095767411000
(which represents 2004-09-21 13:50:11) will be changed to1093989600000
(2004-09-01 00:00:00) when usingResolution.MONTH
.- Parameters:
resolution
- The desired resolution of the date to be returned- Returns:
- the date with all values more precise than
resolution
set to 0 or 1, expressed as milliseconds since January 1, 1970, 00:00:00 GMT
-
roundDate
Limit a date's resolution. For example, the date1095767411000
(which represents 2004-09-21 13:50:11) will be changed to1093989600000
(2004-09-01 00:00:00) when usingResolution.MONTH
.- Returns:
- the date with all values more precise than
resolution
set to 0 or 1, expressed as milliseconds since January 1, 1970, 00:00:00 GMT
-
stringToDate
public static Date stringToDate(String dateString, DateTools.Resolution resolution) throws ParseException - Throws:
ParseException
-
createXPathConstraint
-
createXPathConstraint
public static String createXPathConstraint(Session session, Calendar calendar, DateTools.Resolution roundDateBy) -
getPropertyForResolution
-
getSupportedDateResolutions
Deprecated.UsegetSupportedResolutions()
instead- Returns:
- An array copy of the supported resolutions
-
getSupportedResolutions
-
getSupportedResolutions()
instead