Main Contents

Date functions in DbUnit fixtures

general

I needed some simple functions for writing integegration tests with DbUnit.

Functions like:

NOW()
addDays(NOW(),1)

So I downloaded the source code of DbUnit and added them. You can downdload the patch here, or the patched jar here.

Short Documentation

In every DateTime field in your dbunit fixture you can use the following functions:

addDays(baseDate, days), addHours(baseDate, hours),
addMinutes(baseDate, minutes) and addSeconds(baseDate, seconds)

Example 1:

<table date="addDays(NOW(),2)"/>

Example: 2:

<table date="addDays(NOW(), -2)"/>

Example: 3:

<table date="addSeconds(2000-01-01 00:00:00, 1)"/>

It was very helpful for me, I hope it is also helpful for you. If you find any bugs or have ideas for improving the functionality, do not hesitate to write a comment.

jazzanowak @ July 18, 2009

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>


Feed