List of usage examples for java.time.format DateTimeParseException addSuppressed
public final synchronized void addSuppressed(Throwable exception)
From source file:de.jfachwert.rechnung.Rechnungsmonat.java
private static LocalDate guessLocalDate(String monat, DateTimeParseException ex) { String[] datePatterns = { "d-MMM-yyyy", "d-MM-yyyy", "yyyy-MMM-d", "yyyy-MM-d", "MMM-d-yyyy" }; for (String pattern : datePatterns) { for (Locale locale : Locale.getAvailableLocales()) { try { return LocalDate.parse(monat, DateTimeFormatter.ofPattern(pattern, locale)); } catch (DateTimeParseException ignored) { ex.addSuppressed(new IllegalArgumentException( ignored.getMessage() + " / '" + monat + "' does not match '" + pattern + "'")); }/*from ww w.j a v a 2 s . c om*/ } } throw new InvalidValueException(monat, MONTH, ex); }