Giter VIP home page Giter VIP logo

Comments (5)

w3stling avatar w3stling commented on May 30, 2024

What output do you get if you run the following code?

System.out.println(Locale.getDefault());
var formatter = DateTimeFormatter.ofPattern("E, d LLL yyyy HH:mm:ss O");
System.out.println(formatter);
var timestamp = ZonedDateTime.parse("Sat, 21 Jan 2023 11:12:30 GMT", formatter);
System.out.println(timestamp);

from rssreader.

b3r4t avatar b3r4t commented on May 30, 2024

An exception is thrown:

de_DE
Text(DayOfWeek,SHORT)','' 'Value(DayOfMonth)' 'Text(MonthOfYear,SHORT_STANDALONE)' 'Value(YearOfEra,4,19,EXCEEDS_PAD)' 'Value(HourOfDay,2)':'Value(MinuteOfHour,2)':'Value(SecondOfMinute,2)' 'LocalizedOffset(SHORT)
Exception in thread "main" java.time.format.DateTimeParseException: Text 'Sat, 21 Jan 2023 11:12:30 GMT' could not be parsed at index 0
	at java.base/java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:2052)
	at java.base/java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1954)
	at java.base/java.time.ZonedDateTime.parse(ZonedDateTime.java:600)
	at main.Main.main(Main.java:14)

If I change the locale to English it works fine: Locale.setDefault(Locale.ENGLISH);

I don't know the implementation details of the parser, but it could respect the language property of the RSS feed: <language>en-us</language> if available. Otherwise the parser defaults to the English locale.

from rssreader.

w3stling avatar w3stling commented on May 30, 2024

DateTimeFormatter was using system default locale. Changed it to use Locale.ENGLISH formatting when parsing timestamp strings.

Fixed by PR #77

from rssreader.

w3stling avatar w3stling commented on May 30, 2024

Fixed in release 3.4.2

from rssreader.

b3r4t avatar b3r4t commented on May 30, 2024

Thank you. Everything works now.

from rssreader.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.