Class DateTools

java.lang.Object
org.hippoecm.repository.util.DateTools

public class DateTools extends Object
  • Method Details

    • 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
    • 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.
      Returns:
      An array copy of the supported resolutions
    • getSupportedResolutions

      public static Iterable<DateTools.Resolution> getSupportedResolutions()