PDA

View Full Version : [CLOSED] Date Picker Problem, cannot select years after 2030



jCOM1
1 Mar 2011, 4:15 AM
Hallo,


I'm using a DateField whit DatePicker.
The DateField is with the default format.


The problem is:
When I select a year over the date picker after 2031 and immediately choose a new year.
Is in the date picker 1931 selected.

code sample:

private Widget getSimplyDateField() {
FormPanel panel = new FormPanel();
DateField date = new DateField();

date.setFieldLabel("Date");
FormData formData = new FormData();
panel.add(date, formData);
return panel;
}

micgala
1 Mar 2011, 4:35 AM
I guess this is not a bug.
By default, the dateFormat seems to be "MM/dd/yy".
You could try changing that to "MM/dd/yyyy"

It should then work.

Regards,
Michel.

jCOM1
1 Mar 2011, 4:44 AM
Unfortunately changing the date format is no option for us, because the date pattern is part of our configuration file our customers can change due to their requirements. Sorry but this is obviously a bug.

kjordan2001
2 Mar 2011, 8:49 PM
This is due to the way GWT's DateTimeFormat works:

When parsing a date string using the abbreviated year pattern ("yy"), the parser must interpret the abbreviated year relative to some century. It does this by adjusting dates to be within 80 years before and 20 years after the time the parser instance is created.

However, this is also probably a shortcoming of how GXT handles Field values. I've always disliked how getValue always makes a field recalculate its value based on the rawValue of the underlying HTML field.

jCOM1
8 Mar 2011, 8:04 AM
Can I have a statement from the sencha team if GXT will deal with this problem or not?

Ekambos
9 Mar 2011, 12:32 AM
The support team of GXT has been quiet lately. It looks like GXT 3 is a really good challenge.
So i ll suggest you to get your hands dirty and implements a patch. or maybe give it back to the community ? :)
Cheers,

Alain

micgala
10 Mar 2011, 1:24 AM
You can also open a ticket if you need urgency.

sven
13 Mar 2011, 4:54 AM
This is due to the way GWT's DateTimeFormat works:


However, this is also probably a shortcoming of how GXT handles Field values. I've always disliked how getValue always makes a field recalculate its value based on the rawValue of the underlying HTML field.


This answer is correct. This is obviously not a bug, but by design of how DateTimeFormat and every field in GXT works. The value listed in the fields gets always parsed directly with the configured propertyeditor on a call to getValue. You will need to either customize DateTimeFormat to support this for your application, or change the way how DateField works to not parse the input value but use the value that is selected at the datepicker at the moment (more changes are required for this, because the user could edit the value that was selected)