Interface IDateTimeUtils


public interface IDateTimeUtils
Utility methods so you can perform some time based operation in velocity scripts.

User would need to configure the time zones in Licensing - Host Information in order to evaluate dates/time correctly so 17:00 is 5:00 pm on the user's timezone and not 5 pm UTC server time.

Author:
Fernando Boucquez
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    betweenHours(String fromHourMinute, String toHourMinute)
    Returns if now is between some hours:minutes
    boolean
    betweenHours(Date date, String fromHourMinute, String toHourMinute)
    Returns if the given date is between some hours:minutes
    boolean
    inCronExpression(String cronExpression)
    Evaluates if now applies the given cron expression (the time is a clock click in the expression).
    boolean
    inCronExpression(Date date, String cronExpression)
    Evaluates if the given date applies the given cron expression (the time is a clock click in the expression).
  • Method Details

    • betweenHours

      boolean betweenHours(String fromHourMinute, String toHourMinute)
      Returns if now is between some hours:minutes

      17:00 is between 16:30 and 18:30 17:00 is between 17:00 and 18:30 17:00 is between 16:30 and 17:00 17:00 is NOT between 7:30 and 9:00 23:00 is between 22:30 and 2:00 (Note the 'next date' range) 22:00 is NOT between 22:30 and 2:00 (Note the 'next date' range)

      Parameters:
      fromHourMinute - the start of the range format HH:mm
      toHourMinute - the end of the range format HH:mm
      Returns:
      if now is between the 2 hours:minutes.
    • betweenHours

      boolean betweenHours(Date date, String fromHourMinute, String toHourMinute)
      Returns if the given date is between some hours:minutes

      17:00 is between 16:30 and 18:30 17:00 is between 17:00 and 18:30 17:00 is between 16:30 and 17:00 17:00 is NOT between 7:30 and 9:00 23:00 is between 22:30 and 2:00 (Note the 'next date' range) 22:00 is NOT between 22:30 and 2:00 (Note the 'next date' range)

      Parameters:
      date - the given date.
      fromHourMinute - the start of the range format HH:mm
      toHourMinute - the end of the range format HH:mm
      Returns:
      Returns if the given date is between some hours:minutes
    • inCronExpression

      boolean inCronExpression(String cronExpression)
      Evaluates if now applies the given cron expression (the time is a clock click in the expression). Milliseconds are ignored.

      Example:

      22-01-2015 2:20:55 AM applies * 15-59 2 * * ? 22-01-2015 2:14:59 AM DOES NOT apply * 15-59 2 * * ?

      Parameters:
      cronExpression - the cron expression.
      Returns:
      if now is a click in the cron expression.
    • inCronExpression

      boolean inCronExpression(Date date, String cronExpression)
      Evaluates if the given date applies the given cron expression (the time is a clock click in the expression). Milliseconds are ignored.

      Example:

      22-01-2015 2:20:55 AM applies * 15-59 2 * * ? 22-01-2015 2:14:59 AM DOES NOT apply * 15-59 2 * * ?

      Parameters:
      date - the given date.
      cronExpression - the cron expression.
      Returns:
      if the given date is a click in the cron expression.