Class RelativeDateTimeParser

java.lang.Object
org.dbunit.util.RelativeDateTimeParser

public class RelativeDateTimeParser extends Object

A parser for relative date time string.
The basic format is [now{diff...}{time}].
'diff' consists of two parts 1) a number with a leading plus or minus sign and 2) a character represents temporal unit. See the table below for the supported units. There can be multiple 'diff's and they can be specified in any order.
'time' is a string that can be parsed by LocalTime#parse(). If specified, it is used instead of the current time.
Both 'diff' and 'time' are optional.
Whitespaces are allowed before and after each 'diff'.

Unit

  • y : years
  • M : months
  • d : days
  • h : hours
  • m : minutes
  • s : seconds

Here are some examples.

  • [now] : current date time.
  • [now-1d] : the same time yesterday.
  • [now+1y+1M-2h] : a year and a month from today, two hours earlier.
  • [now+1d 10:00] : 10 o'clock tomorrow.
  • Constructor Details

    • RelativeDateTimeParser

      public RelativeDateTimeParser()
    • RelativeDateTimeParser

      public RelativeDateTimeParser(Clock clock)
  • Method Details