w3stling / rssreader

A simple Java library for reading RSS and Atom feeds
MIT License
152 stars 25 forks source link

Support for custom timestamp parser #105

Closed w3stling closed 1 year ago

w3stling commented 1 year ago

Added DateTimeParser interface for parsing custom timestamp.

For parsing non-standard timestamp for example date format in Italy, dom, 12 mar 2023 12:38:42 GMT

Usage:

// Custom timestamp parser
DateTimeParser timestampParserItaly = (timestamp) -> {
    var formatter = DateTimeFormatter.ofPattern("E, d MMM yyy HH:mm:ss z")
                                     .withLocale(Locale.ITALY);
    return ZonedDateTime.parse(timestamp, formatter);
};

// User custom timestamp parser with optional method setDateTimeParser
var items = new RssReader().setDateTimeParser(timestampParserItaly)
                           .read(URL)
                           .collect(Collectors.toList());