Date in DateField with year resolution switches to BC after entering 0
Open
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:
- Create a DateField
- Set its resolution as Resolution.YEAR
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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