You can try creating a custom deserializer.
@JsonDeserialize(using = CaseInsensitiveLocalTimeDeserializer.class)
@JsonProperty(value = "starttime")
private LocalTime startTime;
@JsonDeserialize(using = CaseInsensitiveLocalTimeDeserializer.class)
@JsonProperty(value = "endtime")
private LocalTime endTime;
with :
public class CaseInsensitiveLocalTimeDeserializer extends JsonDeserializer<LocalTime> {
private final DateTimeFormatter formatter;
public CaseInsensitiveLocalTimeDeserializer() {
this.formatter = DateTimeFormatter.ofPattern("h:mma").withLocale(Locale.ENGLISH);
}
@Override
public LocalTime deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
String timeStr = p.getText().toUpperCase(); // Convert to upper case to handle AM/PM consistently
try {
return LocalTime.parse(timeStr, formatter);
} catch (DateTimeParseException e) {
throw new InvalidFormatException(p, "Failed to parse time", timeStr, LocalTime.class);
}
}
}
And the mapper would look like this when adding the deserializer.
public static ObjectMapper getObjectMapper() {
ObjectMapper objectMapper = new ObjectMapper();
JavaTimeModule javaTimeModule = new JavaTimeModule();
javaTimeModule.addDeserializer(LocalTime.class, new CaseInsensitiveLocalTimeDeserializer());
objectMapper.registerModule(javaTimeModule);
// Other configurations...
return objectMapper;
}
Answer from драган-јованковић on Stack OverflowFacing Issues On IT
facingissuesonitcom.wordpress.com › 2019 › 07 › 19 › com-fasterxml-jackson-databind-exc-invalidformatexception-cannot-deserialize-value-of-type-java-util-date-from-string-mm-dd-yyyy-not-a-valid-representation-for-date-format
[Solved] com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.util.Date` from String “MM/dd/yyyy”: not a valid representation for date format | Facing Issues On IT
November 6, 2023 - InvalidFormatException is subclass of MismatchedInputException. InvalidFormatException occurred because of bad formatting or format not match with the prespecified format of value to deserialize.
GitHub
github.com › FasterXML › jackson-databind › issues › 1722
Deserialization date format error with @ConstructorProperties, @JsonFormat, and @JsonIgnore · Issue #1722 · FasterXML/jackson-databind
August 3, 2017 - Exception in thread "main" com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.util.Date` from String "1970-01-01 00:00:00.000": not a valid representation (error: Failed to parse Date value '1970-01-01 00:00:00.000': Cannot parse date "1970-01-01 00:00:00.000": while it seems to fit format 'yyyy-MM-dd'T'HH:mm:ss.SSSZ', parsing fails (leniency?
Author: FasterXML
GitHub
github.com › FasterXML › jackson-databind › issues › 4577
Cannot deserialize value of type `java.math.BigDecimal` from String "3." (not a valid representation) · Issue #4577 · FasterXML/jackson-databind
June 12, 2024 - com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.math.BigDecimal` from String "5.": not a valid representation at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 10] (through reference chain: TestDTO["value"]) at com.fasterxml.jackson.databind.exc.InvalidFormatException.from(InvalidFormatException.java:67) at com.fasterxml.jackson.databind.DeserializationContext.weirdStringException(DeserializationContext.java:1958) at com.fasterxml.jackson.databind.DeserializationContext.handleWeirdStringValue(Deser
Author: FasterXML
GitHub
github.com › FasterXML › jackson-modules-java8 › issues › 256
Cannot deserialize value of type `java.time.LocalDate` from String "07-OCT-21": Failed to deserialize java.time.LocalDate: · Issue #256 · FasterXML/jackson-modules-java8
December 4, 2022 - Exception in thread "main" com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.time.LocalDate` from String "07-OCT-21": Failed to deserialize java.time.LocalDate: (java.time.format.DateTimeParseException) Text '07-OCT-21' could not be parsed at index 0 at [Source: (String)"{"name":"party","eventDate":"07-OCT-21"}"; line: 1, column: 29] (through reference chain: jolt.custom.date.transformer.model.Event["eventDate"]) at com.fasterxml.jackson.databind.exc.InvalidFormatException.from(InvalidFormatException.java:67) at com.fasterxml.jackson.databind.Des
Author: FasterXML
GitHub
github.com › FasterXML › jackson-databind › issues › 2823
Cannot deserialize enum field · Issue #2823 · FasterXML/jackson-databind
August 19, 2020 - com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `com.bakdata.conquery.integration.json.AnEnum` from String "field": field was not one of [AnEntry] at [Source: (String)"{ "field" : "AnEntry" }"; line: 1, column: 3] at com.fasterxml.jackson.databind.exc.InvalidFormatException.from(InvalidFormatException.java:67) at com.fasterxml.jackson.databind.DeserializationContext.weirdStringException(DeserializationContext.java:1702) at io.dropwizard.jackson.FuzzyEnumModule$PermissiveEnumDeserializer.deserialize(FuzzyEnumModule.java:59) at io.dropwizard.jackson.Fu
Author: FasterXML
Stack Overflow
stackoverflow.com › questions › 71769043 › com-fasterxml-jackson-databind-exc-invalidformatexception-cannot-deserialize-va
spring boot - com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type from String: not one of the values accepted for Enum class - Stack Overflow
April 6, 2022 - com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `models.SeasonType` from String "Season": not one of the values accepted for Enum class: [NO_SEASON, UNKNOWN, SEASON]
Stack Overflow
stackoverflow.com › questions › 76403515 › com-fasterxml-jackson-databind-exc-mismatchedinputexception-cannot-deserialize
java - com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type `[]` from Object value (token `JsonToken.START_OBJECT`) - Stack Overflow
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type `[Lcom.forecast.model.Forecast;` from Object value (token `JsonToken.START_OBJECT`) at [Source: (org.springframework.util.StreamUtils$NonClosingInputStream); line: 1, column: 1] at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59) ~[jackson-databind-2.15.0.jar:2.15.0] at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1752) ~[jackson-databind-2.15.0.jar:2.15.0] at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1526) ~[jackson-databind-2.15.0.jar:2.15.0] at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1473) ~[jackson-databind-2.15.0.jar:2.15.0]
GitHub
github.com › FasterXML › jackson-databind › issues › 1850
`@JsonValue` with integer for enum does not deserialize correctly · Issue #1850 · FasterXML/jackson-databind
December 5, 2017 - com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `com.example.Type` from number 3: index value outside legal index range [0..1] at [Source: (InputStreamReader); line: 1, column: 60] (through reference chain: java.util.ArrayList[0]->com.example.Pojo["type"]) at com.fasterxml.jackson.databind.DeserializationContext.weirdNumberException(DeserializationContext.java:1563) at com.fasterxml.jackson.databind.DeserializationContext.handleWeirdNumberValue(DeserializationContext.java:953) at com.fasterxml.jackson.databind.deser.std.EnumDeserializer.deserialize(EnumDeserializer.java:200) at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeSetAndReturn(MethodProperty.java:149) If I add a @JsonCreator to a static method that matches the value to the internal field, the enum can be deserialized correctly.
Author: FasterXML
Java Code Geeks
examples.javacodegeeks.com › home › java development › core java › json › jackson
Jackson Exceptions - Examples Java Code Geeks - 2026
June 21, 2020 - The deserialization after applying the fix will be successful without any exception at runtime. Consider the following model class Customer with two fields id and name. ... The below code attempts to deserialize an array of JSON objects of type Customer to an instance of the Customer class.
GitHub
github.com › FasterXML › jackson-databind › issues › 2754
Deserializing enum error by using int/Integer value with @JsonValue · Issue #2754 · FasterXML/jackson-databind
June 9, 2020 - RED com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `cn.zzzzbw.springboot.Test$ColorEnum` from number 10: index value outside legal index range [0..2] at [Source: (String)"10"; line: 1, column: 1] at com.fasterxml.jackson.databind.exc.InvalidFormatException.from(InvalidFormatException.java:67) at com.fasterxml.jackson.databind.DeserializationContext.weirdNumberException(DeserializationContext.java:1710) at com.fasterxml.jackson.databind.DeserializationContext.handleWeirdNumberValue(DeserializationContext.java:992) at com.fasterxml.jackson.databind.de
Author: FasterXML
Microsoft Learn
learn.microsoft.com › en-us › answers › questions › 1320266 › java-cosmosdb-how-to-fix-jackson-mismatchedinputex
Java CosmosDB: How to fix Jackson MismatchedInputException for deserializing value from Object value (token `JsonToken.START_OBJECT`) - Microsoft Q&A
67 more Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type `` from Object value (token `JsonToken.START_OBJECT`) at [Source: (byte[])"{"id":""[truncated 681 bytes]; line: 1, column: 1] at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59) at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1746) at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1520) at com.fasterxml.jackson.databind.D
GitHub
github.com › FasterXML › jackson-databind › issues › 5271
`EnumDeserializer` fails to deserialize Enums with `@JsonValue` - uses table with name() key instead of `@JsonValue` key · Issue #5271 · FasterXML/jackson-databind
August 22, 2025 - tools.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `org.springframework.data.couchbase.core.mapping.MappingCouchbaseConverterTests$MyEnum` from String "10%": not one of the values accepted for Enum class: [T30, T20, T10] at [No location information] at tools.jackson.databind.exc.InvalidFormatException.from(InvalidFormatException.java:37) at tools.jackson.databind.DeserializationContext.weirdStringException(DeserializationContext.java:1977) at tools.jackson.databind.DeserializationContext.handleWeirdStringValue(DeserializationContext.java:1320) at tools.jackson.
Author: FasterXML
GitHub
github.com › dependency-check › DependencyCheck › issues › 6191
InvalidFormatException: Cannot deserialize value of type `java.util.Date` from String "2023-12-01T15:09:26..642Z" · Issue #6191 · dependency-check/DependencyCheck
December 1, 2023 - null)) at [Source: (InputStreamReader); line: 4, column: 21] (through reference chain: org.owasp.dependencycheck.data.knownexploited.json.KnownExploitedVulnerabilitiesSchema["dateReleased"]) at com.fasterxml.jackson.databind.exc.InvalidFormatException.from (InvalidFormatException.java:67) at com.fasterxml.jackson.databind.DeserializationContext.weirdStringException (DeserializationContext.java:2002) at com.fasterxml.jackson.databind.DeserializationContext.handleWeirdStringValue (DeserializationContext.java:1230) at com.fasterxml.jackson.databind.deser.std.StdDeserializer._parseDate (StdDeseria
Author: dependency-check
GitHub
github.com › zalando › problem-spring-web › issues › 206
Situation where an exception happens while parsing JSON request · Issue #206 · zalando/problem-spring-web
August 21, 2018 - Caused by: com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.lang.Long` from String "test": not a valid Long value at [Source: (PushbackInputStream); line: 2, column: 8] (through reference chain: java.util.ArrayList[0]->test.Dto["id"]) at com.fasterxml.jackson.databind.exc.InvalidFormatException.from(InvalidFormatException.java:67) at com.fasterxml.jackson.databind.DeserializationContext.weirdStringException(DeserializationContext.java:1548) at com.fasterxml.jackson.databind.DeserializationContext.handleWeirdStringValue(DeserializationContext.jav