Package org.hippoecm.repository.util
Class DateTools
- java.lang.Object
-
- org.hippoecm.repository.util.DateTools
-
public class DateTools extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DateTools.Resolution
Specifies the time granularity.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static 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[]
getSupportedDateResolutions()
Deprecated.UsegetSupportedResolutions()
insteadstatic Iterable<DateTools.Resolution>
getSupportedResolutions()
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 Detail
-
dateToString
public static String dateToString(Date date, DateTools.Resolution resolution)
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
public static String timeToString(long time, DateTools.Resolution resolution)
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
public static long round(long time, DateTools.Resolution resolution)
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
public static Calendar roundDate(long time, DateTools.Resolution resolution)
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
public static String createXPathConstraint(Session session, Calendar calendar)
-
createXPathConstraint
public static String createXPathConstraint(Session session, Calendar calendar, DateTools.Resolution roundDateBy)
-
getPropertyForResolution
public static String getPropertyForResolution(String property, DateTools.Resolution resolution)
-
getSupportedDateResolutions
@Deprecated public static DateTools.Resolution[] getSupportedDateResolutions()
Deprecated.UsegetSupportedResolutions()
instead- Returns:
- An array copy of the supported resolutions
-
getSupportedResolutions
public static Iterable<DateTools.Resolution> getSupportedResolutions()
-
-