-
Notifications
You must be signed in to change notification settings - Fork 2
ParsingDates
jochenwierum edited this page Jul 9, 2012
·
1 revision
Parsing Dates in Fit is not easy. Fit processing the string s using DateFormat.getDateInstance().parse(s). This has several drawbacks: first of all, the test file must be localized. That means that a English date would not necessarily work on German systems. Secondly, the format can not be specified. Third: Fit cannot handle times.
FitGoodies brings its own TypeAdapter for handling dates. This adapter can be set up using Fixtures, so the behavior is much more dynamic. Here is an example:
fitgoodies.date.SetupFixture | |
---|---|
locale | de_DE |
format | dd.MM.yyyy hh:mm:ss |
Now, every time FitGoodies needs a Date, it gets it using the following Code: new SimpleDateFormat("MM.dd.yyyy hh:mm:ss", new Locale("de", "DE")).parse(string)
.
You can also change the behavior for individual columns (see Parameters for more information):
MyFixture | |
---|---|
date1 | date2[en_US, MM/dd/yyyy] |
24.12.2009 22:00 | 12/24/2009 |