zach-m / jonix

Commercial-grade library for extracting data from ONIX sources
Apache License 2.0
57 stars 17 forks source link

Custom date deserializer #7

Closed phillippc closed 4 years ago

phillippc commented 5 years ago

First of all I would like to extend my gratitude for the work on this library! Is there a way to define a custom date deserializer for this case: java.lang.RuntimeException: java.text.ParseException: Unparseable date: "201910" at com.tectonica.jonix.util.JonixUtil.parseYYYYMMDD(JonixUtil.java:70)

Some of the onix feeds we receive, come with crappy date formats. Ive been googling around but could not find anything. Any help is much appreciated! Regards, Phillipp

zach-m commented 5 years ago

@phillippc I see that parseYYYYMMDD() gets called only by PublishingDetails, where indeed there's a "TODO" note for more careful date manipulation..

What are you doing exactly that takes you to this code path? maybe paste the entire stack-trace here.

Also, which version of Jonix are you using? and do you compile from Code or just using it as a dependency?

zach-m commented 5 years ago

Anyway, apparently "201910" is not a "crappy date format", and is in fact valid. I added a fix to the code, but unless you're building from source you won't see it. I'll do a minor release soon.