apache/dubbo · error · IllegalStateException

Failed to parse date {value} by format {DATE_FORMAT}, cause:

Error message

Failed to parse date {value} by format {DATE_FORMAT}, cause: {cause}

What it means

Thrown by CompatibleTypeUtils.compatibleTypeConvert when parsing a String into java.util.Date, java.sql.Date, java.sql.Timestamp, or java.sql.Time fails. The parser uses the fixed format 'yyyy-MM-dd HH:mm:ss'; a ParseException from SimpleDateFormat is wrapped in this IllegalStateException carrying the original message and cause.

Source

Thrown at dubbo-common/src/main/java/org/apache/dubbo/common/utils/CompatibleTypeUtils.java:120

            }
            if (type == Date.class
                    || type == java.sql.Date.class
                    || type == java.sql.Timestamp.class
                    || type == java.sql.Time.class) {
                try {
                    Date date = new SimpleDateFormat(DATE_FORMAT).parse(string);
                    if (type == java.sql.Date.class) {
                        return new java.sql.Date(date.getTime());
                    }
                    if (type == java.sql.Timestamp.class) {
                        return new java.sql.Timestamp(date.getTime());
                    }
                    if (type == java.sql.Time.class) {
                        return new java.sql.Time(date.getTime());
                    }
                    return date;
                } catch (ParseException e) {
                    throw new IllegalStateException(
                            "Failed to parse date " + value + " by format " + DATE_FORMAT + ", cause: "
                                    + e.getMessage(),
                            e);
                }
            }
            if (type == java.time.LocalDateTime.class) {
                if (StringUtils.isEmpty(string)) {
                    return null;
                }
                return LocalDateTime.parse(string);
            }
            if (type == java.time.LocalDate.class) {
                if (StringUtils.isEmpty(string)) {
                    return null;
                }
                return LocalDate.parse(string);
            }
            if (type == java.time.LocalTime.class) {

View on GitHub (pinned to 3a3043227f)

Solutions

  1. Format the source string as 'yyyy-MM-dd HH:mm:ss' (24-hour, space separator, zero-padded).
  2. If the value is epoch millis, convert it to a Long and target a long/Date via a numeric path instead.
  3. If you need ISO-8601 or another format, parse it yourself before handing the value to compatibleTypeConvert, or use java.time types.
  4. Inspect the chained ParseException cause for the exact unparseable position.

Example fix

// before
Object d = CompatibleTypeUtils.compatibleTypeConvert("2024-01-01", Date.class); // throws

// after
Object d = CompatibleTypeUtils.compatibleTypeConvert("2024-01-01 00:00:00", Date.class);
// or parse the desired format yourself:
Date d = new SimpleDateFormat("yyyy-MM-dd").parse("2024-01-01");
Defensive patterns

Strategy: validation

Validate before calling

String s = /* ... */;
try {
    new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(s);
} catch (java.text.ParseException pe) {
    throw new IllegalArgumentException("Date value must match 'yyyy-MM-dd HH:mm:ss': " + s, pe);
}
CompatibleTypeUtils.compatibleTypeConvert(s, Date.class);

Type guard

static boolean matchesDubboDateFormat(String s) {
    if (s == null || s.length() != 19) return false;
    try { new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(s); return true; }
    catch (java.text.ParseException e) { return false; }
}

Try / catch

try {
    Object d = CompatibleTypeUtils.compatibleTypeConvert(s, Date.class);
} catch (IllegalStateException e) {
    if (e.getCause() instanceof java.text.ParseException) {
        // reformat the source or fall back to a custom parser
    } else throw e;
}

Prevention

When it happens

Trigger: compatibleTypeConvert(stringValue, Date.class / java.sql.Date.class / Timestamp.class / Time.class) where stringValue does not match 'yyyy-MM-dd HH:mm:ss' — e.g. '2024-01-01', '01/01/2024 12:00', '2024-01-01T12:00:00Z' (ISO), or any locale-specific format.

Common situations: RPC/config deserialization of a Date field from a producer that used a different date format (ISO-8601, epoch millis, US locale); a config timestamp written as date-only without time; version change where the producer's serialization format shifted. Note java.time.LocalDateTime/LocalDate use their own parsing paths, not this format.

Understand the failure class

Related errors


AI-assisted analysis of apache/dubbo@3a3043227f (2026-08-14). Data as JSON: /api/errors/4fe71c10026b5e58. Report an issue: GitHub.