Date relative to current in the DBUnit dataset

前端 未结 4 1336
情话喂你
情话喂你 2021-02-04 08:09

I\'m wondering if there is any way to specify for example tomorrow as date in the DBUnit XML dataset. Sometimes code logic is different for dates in future and dates in the past

4条回答
  •  北荒
    北荒 (楼主)
    2021-02-04 08:23

    A new relative date/time syntax has been added in DbUnit 2.7.0 and you can now write [now+1d] to set tomorrow's date without any extra setup.

    
      
    
    

    The doc is here:
    http://dbunit.sourceforge.net/datatypes.html#relativedatetime

    A few examples from the doc:

    • [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

提交回复
热议问题