"MM-dd" mapping is not working, throwing exception in leap year day (feb 29, 2024))

Hi Team,

We have the below mapping for saving the date of birth and date of joining with the below format ("MM-dd"), but the system is taking the year 1970 (not a leap year) and throwing the exception

Mapping :
"dob": {
"type": "date",
"format": "MM-dd"
},
"doj": {
"type": "date",
"format": "MM-dd"
},

Exception:

[56]:ElasticSerachDAO:indexDocument:exception:
org.elasticsearch.index.mapper.MapperParsingException: failed to parse field [doj] of type [date] in document with id '2240280'. Preview of field's value: '02-29'
	
Caused by: org.elasticsearch.common.io.stream.NotSerializableExceptionWrapper: date_time_exception: Invalid date 'February 29' as '1970' is not a leap year	

Please review and update us on this

I think there is a disconnect..

Hi @navaneethan

If you define a date type a year is expected as part of the value if you do not provide one1970 Start of Unix Epoch is assumed.

If you want the date to use the current year you will need to provide one.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.