### Elasticsearch Version

8.4.2

### Installed Plugins

_No response_

### Java Version

_bundled_

### OS Version

`Linux yrodiere.redhat 5.19.8-200.fc36.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Sep 8 19:02:21 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux`

### Problem Description

Since Elasticsearch 8.4.2, running a `match` query on a field of type `date` with format `uuuu` will give strange results for years below 1971, similar to running a range query with the range `[<your year>, 1970]`.

Yes, that's very weird.

This bug was not present in Elasticsearch 8.4.1.

### Steps to Reproduce

```shell
# Just to make it easier to re-run the test
curl -XDELETE localhost:9200/mytest/\?pretty 1>&2 2>/dev/null || true
# Property of type `date` with format `uuuu`
curl -XPUT -H "Content-Type: application/json" localhost:9200/mytest/\?pretty -d'{"mappings":{"properties":{"myyear":{"type":"date","format":"uuuu"}}}}'
# Index year 1971
curl -XPUT -H "Content-Type: application/json" localhost:9200/mytest/_doc/1\?pretty\&refresh=true -d'{"myyear":"1971"}'
# Index two different years below 1971
curl -XPUT -H "Content-Type: application/json" localhost:9200/mytest/_doc/2\?pretty\&refresh=true -d'{"myyear":"1970"}'
curl -XPUT -H "Content-Type: application/json" localhost:9200/mytest/_doc/3\?pretty\&refresh=true -d'{"myyear":"1969"}'
curl -XPUT -H "Content-Type: application/json" localhost:9200/mytest/_doc/4\?pretty\&refresh=true -d'{"myyear":"1500"}'
curl -XPUT -H "Content-Type: application/json" localhost:9200/mytest/_doc/6\?pretty\&refresh=true -d'{"myyear":"0050"}'
curl -XPUT -H "Content-Type: application/json" localhost:9200/mytest/_doc/7\?pretty\&refresh=true -d'{"myyear":"-42"}'
# Search for year 1970: only 1970 matches
curl -XPOST -H "Content-Type: application/json" localhost:9200/mytest/_search\?pretty -d'{"query":{"match":{"myyear":{"query":"1970"}}}}'
# Search for year 1969: both 1969 and 1970 match (???) but not 1971
curl -XPOST -H "Content-Type: application/json" localhost:9200/mytest/_search\?pretty -d'{"query":{"match":{"myyear":{"query":"1970"}}}}'
# Search for year 1500: 1500, 1969 and 1970 match (???) but not 1971
curl -XPOST -H "Content-Type: application/json" localhost:9200/mytest/_search\?pretty -d'{"query":{"match":{"myyear":{"query":"1500"}}}}'
# Search for year 0001: 0050, 1500, 1969 and 1970 match (???) but not 1971
curl -XPOST -H "Content-Type: application/json" localhost:9200/mytest/_search\?pretty -d'{"query":{"match":{"myyear":{"query":"0001"}}}}'
```

### Logs (if relevant)

(Incorrect) result of the last two requests in the script above with Elasticsearch 8.4.2:

```json
{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 3,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "mytest",
        "_id" : "2",
        "_score" : 1.0,
        "_source" : {
          "myyear" : "1970"
        }
      },
      {
        "_index" : "mytest",
        "_id" : "3",
        "_score" : 1.0,
        "_source" : {
          "myyear" : "1969"
        }
      },
      {
        "_index" : "mytest",
        "_id" : "4",
        "_score" : 1.0,
        "_source" : {
          "myyear" : "1500"
        }
      }
    ]
  }
}
{
  "took" : 2,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 4,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "mytest",
        "_id" : "2",
        "_score" : 1.0,
        "_source" : {
          "myyear" : "1970"
        }
      },
      {
        "_index" : "mytest",
        "_id" : "3",
        "_score" : 1.0,
        "_source" : {
          "myyear" : "1969"
        }
      },
      {
        "_index" : "mytest",
        "_id" : "4",
        "_score" : 1.0,
        "_source" : {
          "myyear" : "1500"
        }
      },
      {
        "_index" : "mytest",
        "_id" : "6",
        "_score" : 1.0,
        "_source" : {
          "myyear" : "0050"
        }
      }
    ]
  }
}
```

(Correct) result of the last two requests in the script above with Elasticsearch 8.4.1:

```json
{
  "took" : 3,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 1,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "mytest",
        "_id" : "4",
        "_score" : 1.0,
        "_source" : {
          "myyear" : "1500"
        }
      }
    ]
  }
}
{
  "took" : 2,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 0,
      "relation" : "eq"
    },
    "max_score" : null,
    "hits" : [ ]
  }
}

```
server/src/main/java/org/elasticsearch/common/time/JavaDateFormatter.java
/**
    * A default consumer that allows to round up fields (used for range searches, optional fields missing)
    * it relies on toString implementation of DateTimeFormatter and ChronoField.
    * For instance for pattern
    * the parser would have a toString()
    * <code>
    *  Value(MonthOfYear,2)'/'Value(DayOfMonth,2)'/'Value(YearOfEra,4,19,EXCEEDS_PAD)'
    * 'Value(ClockHourOfAmPm,2)':'Value(MinuteOfHour,2)' 'Text(AmPmOfDay,SHORT)
    * </code>
    * and ChronoField.CLOCK_HOUR_OF_AMPM would have toString() ClockHourOfAmPm
    * this allows the rounding logic to default CLOCK_HOUR_OF_AMPM field instead of HOUR_OF_DAY
    * without this logic, the rounding would result in a conflict as HOUR_OF_DAY would be missing, but CLOCK_HOUR_OF_AMPM would be provided
    */
    private static final BiConsumer<DateTimeFormatterBuilder, DateTimeFormatter> DEFAULT_ROUND_UP = (builder, parser) -> {
        String parserAsString = parser.toString();
        if (parserAsString.contains(ChronoField.MONTH_OF_YEAR.toString())) {
            builder.parseDefaulting(ChronoField.MONTH_OF_YEAR, 1L);
        }
        if (parserAsString.contains(ChronoField.DAY_OF_MONTH.toString())) {
            builder.parseDefaulting(ChronoField.DAY_OF_MONTH, 1L);
        }
        if (parserAsString.contains(ChronoField.CLOCK_HOUR_OF_AMPM.toString())) {