Class DateTools


  • public class DateTools
    extends Object
    • 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 converted
        resolution - the desired resolution, see round(long, DateTools.Resolution)
        Returns:
        a string in format yyyyMMddHHmmssSSS or shorter, depeding on resolution; 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 GMT
        resolution - the desired resolution, see round(long, DateTools.Resolution)
        Returns:
        a string in format yyyyMMddHHmmssSSS or shorter,depending on resolution; using UTC as timezone
      • round

        public static long round​(long time,
                                 DateTools.Resolution resolution)
        Limit a date's resolution. For example, the date 1095767411000 (which represents 2004-09-21 13:50:11) will be changed to 1093989600000 (2004-09-01 00:00:00) when using Resolution.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 date 1095767411000 (which represents 2004-09-21 13:50:11) will be changed to 1093989600000 (2004-09-01 00:00:00) when using Resolution.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
      • createXPathConstraint

        public static String createXPathConstraint​(Session session,
                                                   Calendar calendar)