DateTimeParseException

java.time.format.DateTimeParseException: Text '2024-13-01' could not be parsed

Quick Answer

The date/time string does not match the expected format or contains invalid values. Check the format pattern and input values.

Why This Happens

DateTimeParseException is thrown by LocalDate.parse(), LocalDateTime.parse(), and DateTimeFormatter when the input string does not match the expected pattern or contains invalid date values like month 13 or day 32.

The Problem

LocalDate date = LocalDate.parse("01/15/2024"); // Expects yyyy-MM-dd format

The Fix

DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
LocalDate date = LocalDate.parse("01/15/2024", formatter);

Step-by-Step Fix

  1. 1

    Identify the parse error

    Read the exception message for the input string and the position where parsing failed.

  2. 2

    Check the format pattern

    Verify the DateTimeFormatter pattern matches the actual input format. Common: yyyy-MM-dd, MM/dd/yyyy, dd-MMM-yyyy.

  3. 3

    Fix the pattern or input

    Create a DateTimeFormatter with the correct pattern, or normalize the input string to match the expected format.

Bugsly catches this automatically

Bugsly's AI analyzes this error pattern in real-time, explains what went wrong in plain English, and suggests the exact fix — before your users even report it.

Try Bugsly free