enasequence / sequencetools

Webin sequence validation API.
Apache License 2.0
10 stars 3 forks source link

Validation of dates in FlatFile genome annotations failing with system locale set to sv_SE #132

Closed wna-se closed 1 year ago

wna-se commented 1 year ago

Running validation on a FlatFile genome annotations with system locale set to sv_SE will fail with ERROR: Invalid date: 23-FEB-2023 [ line: 9]. Changing the locale to en_UK (e.g. java -Duser.language=en -Duser.country=UK) and running the same command will pass the validation without the error.

In FlatFileUtils.java I see that the defaultLocale is set to UK on line 236 and I assume this should happen before or as the dateMonYear object created (e.g. new SimpleDateFormat("dd-MMM-yyyy", Locale.UK)).

raskoleinonen commented 1 year ago

Replicated the problem and prepared a fix: https://github.com/enasequence/sequencetools/pull/135

Pending approval and integration testing.

raskoleinonen commented 1 year ago

The locale problem affecting dates has been fixed by using DateTimeFormatter (threadsafe) and setting the locale to UK. https://github.com/enasequence/sequencetools/commit/dfbc6cd10083b6fa109bb3aec977ef13d6cec0b5