DateField with empty value and placeholder

Hi!

I have a problem with DateField using custom empty value.
In our system we never store dates as null, instead we use the sentinel date “1900-01-01” to represent an absent/unspecified/empty date.

The docs of HasValue#getEmptyValue() implies that one should be able to redefine what is considered empty:

LocalDate emptyDate = LocalDate.parse("1900-01-01");

DateField field = new DateField()
{
    @Override
    public boolean isEmpty()
    {
        return getValue() == null || getValue().equals(emptyDate);
    }

    @Override
    public LocalDate getEmptyValue()
    {
        return emptyDate;
    }
};
field.setPlaceholder("yyyy-MM-dd");
field.setValue(emptyDate); // Shows "1900-01-01" instead of placeholder
field.setValue(null); // Shows placeholder "yyyy-MM-dd"

I expect to see placeholder when value is equal to empty value, but it only works when value is null.
Docs of DateField#setPlaceholder states “Sets the placeholder text. The placeholder is text that is displayed when the field would otherwise be empty, to prompt the user for input.” so it seems this does not work as one would expect?

Overriding #formatDate(LocalDate) doesn’t work either:

@Override
protected String formatDate(LocalDate value)
{
    if (isEmpty())
    {
        return getPlaceholder();
    }
    else
    {
        return super.formatDate(value);
    }
}

Using Vaadin 8.6.1

Thanks!
// Martin

Might be a a bit confusing documentation at the very least. Could you create a ticket at https://github.com/vaadin/framework/issues/ ?

I’ve added issue: https://github.com/vaadin/framework/issues/11359

Thanks!