public function decode($value, Field $field, Codec $codec = null)
    {
        if (empty($value)) {
            return null;
        }

        if ($value instanceof \DateTimeInterface) {
            // ensures we're always in UTC and have no time parts.
            $value = $value->format('Y-m-d');
        }

        $date = \DateTimeImmutable::createFromFormat('!Y-m-d', $value, $this->getUtcTimeZone());
        if ($date instanceof \DateTimeImmutable) {
            return $date;
        }

        throw new DecodeValueFailed(
            $value,
            $field,
            sprintf(
                'Format must be [Y-m-d].  Errors: [%s]',
                print_r(\DateTimeImmutable::getLastErrors(), true)
            )
        );
    }
public function decode($value, Field $field, Codec $codec = null)
    {
        if (empty($value)) {
            return null;
        }

        if ($value instanceof \DateTimeInterface) {
            // ensures we're always in UTC and have no time parts.
            $value = $value->format('Y-m-d');
        }

        $date = \DateTimeImmutable::createFromFormat('!Y-m-d', $value, $this->getUtcTimeZone());
        if ($date instanceof \DateTimeImmutable) {
            return $date;
        }

        throw new DecodeValueFailed(
            $value,
            $field,
            sprintf(
                'Format must be [Y-m-d].  Errors: [%s]',
                print_r(\DateTimeImmutable::getLastErrors(), true)
            )
        );
    }
{@inheritdoc}