hsac-fitnesse-fixtures
hsac-fitnesse-fixtures copied to clipboard
Converting to yyyy-MM-ddTHH:mm:ss returns illegal character pattern 'T'
I'm trying to run a simple test where I try to convert returned values used by the database into an iso standard notation for XML as per: https://www.w3.org/TR/xmlschema-2/#formatdetails
Unfortunately the SimpleDateFormat used in the DateFormatFixture doesn't support the 'T' symbol. Which results in errors. This stackoverflow solution suggest that Instant is a better practice, so perhaps that should be the way to go? https://stackoverflow.com/questions/2597083/illegal-pattern-character-t-when-parsing-a-date-string-to-java-util-date
Reproduction:
|script |nl.hsac.fitnesse.fixture.slim.DateFormatFixture |
|set date format|yyyy-MM-dd hh:mm:ss |
|$stamp= |timestamp for date|2019-11-06 15:02:29 |
|show |format timestamp |$stamp|as|yyyy-MM-ddTHH:mm:ssZ|
Error:
__EXCEPTION__:java.lang.IllegalArgumentException: Illegal pattern character 'T'
Applicable Versions:
- JDK: 1.8.0_181
- Fitnesse: 26.0.24
- HSAC: 5.2.8
- jackson-datatype-jsr310: 2.13.3
I'm just starting out with Fitness so suggestions are appreciated. Figured I'd report it regardless, should there be a better way to do this please let me know. Please close if redundant, thanks!
@GerwinLaagland maybe it would indeed be better if DateFormatFixture
would use an Instant
instead of its current date formatting implementation. But I fear that might cause backwards compatibility issues for people that rely on its current formatting approach.
A PR to have a date formatting fixture with a more modern approach would be welcome, if you feel like making one.
For now I believe the simplest approach for you to move forward is just to adjust your pattern to use the formatting options currently supported. For that you need to make explicit that the T
is not a placeholder but a literal you want to use. I believe that can be done by specifying yyyy-MM-dd'T'HH:mm:ssZ
.