Search code examples
javafxdate-formattingdate-conversionstring-conversionlocaldate

LocalDate pattern that shows day as weekday


I search for a pattern which looks like this: Thu, 11. 05. 1999 So I tried this syntax:

String pattern = "DDD, dd. mm. uuuu";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);

But it won't work. When trying to format a LocalDate I get java.time.temporal.UnsupportedTemporalTypeException: Unsupported field: MinuteOfHour.


Solution

  • A look into the official documentation of Java explaining the format pattern syntax is always good:

    • E = day-of-week
    • M = month
    • m = minute

    So you should try this pattern:

    EEE, dd. MM. uuuu
    

    And setting the locale explicitly to English is also a good idea.