public class DateTools extends Object
Modifier and Type | Class and Description |
---|---|
static class |
DateTools.Resolution
Specifies the time granularity.
|
Modifier and Type | Method and Description |
---|---|
static String |
createXPathConstraint(javax.jcr.Session session,
Calendar calendar) |
static String |
createXPathConstraint(javax.jcr.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.
Use
getSupportedResolutions() instead |
static 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.
|
public static String dateToString(Date date, DateTools.Resolution resolution)
date
- the date to be convertedresolution
- the desired resolution, see round(long, DateTools.Resolution)
yyyyMMddHHmmssSSS
or shorter, depeding on resolution
; using
UTC as timezonepublic static String timeToString(long time, DateTools.Resolution resolution)
time
- the date expressed as milliseconds since January 1, 1970, 00:00:00 GMTresolution
- the desired resolution, see round(long, DateTools.Resolution)
yyyyMMddHHmmssSSS
or shorter,depending on resolution
; using UTC as timezonepublic static long round(long time, DateTools.Resolution resolution)
1095767411000
(which represents 2004-09-21 13:50:11) will be changed to
1093989600000
(2004-09-01 00:00:00) when using
Resolution.MONTH
.resolution
- The desired resolution of the date to be returnedresolution
set to 0 or 1, expressed as milliseconds since January 1, 1970, 00:00:00 GMTpublic static Calendar roundDate(long time, DateTools.Resolution resolution)
1095767411000
(which represents 2004-09-21 13:50:11) will be changed to
1093989600000
(2004-09-01 00:00:00) when using
Resolution.MONTH
.resolution
set to 0 or 1, expressed as milliseconds since January 1, 1970, 00:00:00 GMTpublic static Date stringToDate(String dateString, DateTools.Resolution resolution) throws ParseException
ParseException
public static String createXPathConstraint(javax.jcr.Session session, Calendar calendar)
public static String createXPathConstraint(javax.jcr.Session session, Calendar calendar, DateTools.Resolution roundDateBy)
public static String getPropertyForResolution(String property, DateTools.Resolution resolution)
@Deprecated public static DateTools.Resolution[] getSupportedDateResolutions()
getSupportedResolutions()
insteadpublic static Iterable<DateTools.Resolution> getSupportedResolutions()
Copyright © 2007–2017 Hippo B.V. (http://www.onehippo.com). All rights reserved.