src/Definition/Type/DateType.php
public function normalize($data)
    {
        if (\is_string($data)) {
            try {
                $data = new \DateTimeImmutable($data);
            } catch (\Exception $e) {
                throw new NormalizationException('The value must be a date');
            }
        }

        if (!$data instanceof \DateTimeInterface) {
            throw new NormalizationException(
                'The value must be an instance of \DateTimeInterface'
            );
        }

        return $data->format($this->format);
    }
public function normalize($data)
    {
        if (\is_string($data)) {
            try {
                $data = new \DateTimeImmutable($data);
            } catch (\Exception $e) {
                throw new NormalizationException('The value must be a date');
            }
        }

        if (!$data instanceof \DateTimeInterface) {
            throw new NormalizationException(
                'The value must be an instance of \DateTimeInterface'
            );
        }

        return $data->format($this->format);
    }
{@inheritdoc}