This is what you can do for OffsetDateTime :
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "uuuu-MM-dd'T'HH:mm:ss.SSSXXXX") private OffsetDateTime timeOfBirth;
For LocalDateTime, you cannot use XXXX (zone offset) because there is no offset information. Therefore, you can refuse it. But ISO8601 does not recommend using Local Time as it is ambiguous:
If UTC relationship information is not provided with a time representation, the time is considered local. Although it may be safe to assume local time when communicating in the same time zone, it is ambiguous when used when communicating in different time zones. Even within the same geographical time zone, some local times will be ambiguous if the region observes daylight saving time. It is usually preferable to specify the time zone (zone designation) using standard notation.
source share