Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple way to override ROME's DateParser?

Tags:

java

rss

rome

An RSS 2.0 feed I need to process returns date entries which ROME's DateParser cannot parse, delivering null for all dates. More than that, no suitable SimpleDateFormat pattern exists (which could simply be specified in rome.properties), so the input needs to be pre-processed before it can be parsed. ROME's DateParser already does such things internally, like replacing "UT" in RFC822 date input by "GMT" before feeding it to the Java DateFormat parser. I just need to add a similar modification.

What I'm doing now is to include within my project copies of ROME's RSS20Parser.java and all feed parser classes it extends, as far as necessary to cover all references to ROME's DateParser, and provide my own DateParser class which the feed parser classes then reference instead of the orginal DateParser.

Given ROME's plugin structure, I was hoping to be able to simply plug in my own DateParser, but found no way to do so. Did I miss something? Can I somehow use ROME with my own DateParser, but without having to replicate all the feed parser classes which are expected to use it?

like image 406
Hubertus Bigend Avatar asked Jan 24 '26 20:01

Hubertus Bigend


1 Answers

See the manual here To customize date format for the DateParser in ROME, you need to create your custom rome.properties with the proper datetime.extra.masks, e.g:

datetime.extra.masks=EEE, dd MMM yyyy HH:mm:ss z

Put the custom properties file in src/main/resources. All rome.properties files will be aggregated upon loading.

like image 59
canhnt Avatar answered Jan 27 '26 11:01

canhnt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!