vaadin / vaadin/framework

Date in DateField with year resolution switches to BC after entering 0

Open
#8,347 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Stale v7
Dominant language
Java
Stars
1.8k
Forks
717
Avg merge
2d 6h
Merged PRs (30d)
3

Description

We are using Vaadin 7.5.7. Problem still persists in 7.7.6

Reproduction steps:

  1. Create a DateField
  2. Set its resolution as Resolution.YEAR
  3. Enter 0 into this DateField and switch focus

After that any selected or inputed year is interpreted as year BC.

Example UI:

@Theme("mytheme")
public class MyUI extends UI {

    @Override
    protected void init(VaadinRequest vaadinRequest) {
        final VerticalLayout layout = new VerticalLayout();

        // Main part - create date field with year resolution
        DateField dateField = new DateField();
        dateField.setCaption("Field with year resolution");
        dateField.setResolution(Resolution.YEAR);

        // Add control to show the value currently in dateField
        Button button = new Button("Show value in field");
        button.addClickListener(event -> {
            SimpleDateFormat formatWithEra = new SimpleDateFormat("yyyy.MM.dd G 'at' HH:mm:ss z");
            Label label = new Label(formatWithEra.format(dateField.getValue()));
            layout.addComponent(label);
        });

        layout.addComponents(dateField, button);
        layout.setMargin(true);
        layout.setSpacing(true);
        setContent(layout);
    }
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue using a Vaadin DateField configured with Resolution.YEAR, entering 0, and changing focus. Start by tracing DateField's year-resolution handling and compare the resulting value with the SimpleDateFormat output shown in the example. Done means entering 0 no longer causes later selected or entered years to be interpreted as BC.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.