Change datetime in program does strange things for February and March [message #1773832] |
Thu, 05 October 2017 09:04 |
Wim Anckaert Messages: 32 Registered: December 2012 |
Member |
|
|
Hi,
Use case:
We have a general date widget datetime : SWT.CALENDAR for all our dates in a popup.
In one case we want to set the birthdate of a person running RAP on a mobile device.
You need a lot of clicks to get to, for example 1971.
So we created two comboboxes above the datetime to change year and month. So the user has multiple options for change the year and month.
That works ok !
We found what i think is a bug.
If the date is set to 2017/03/31 (YYYY/MM/DD) and via the combobox we change it to februari, we want it to be the first of February, but in the gui we see the first of March.
If we ask the datetime wich date is selected, it says first of February. So the widget is correct but it shows the wrong month.
see below a basic snippet to reproduce the problem.
We use RAP 3.1.1, I don't know if it also occures in RAP 3.2
final DateTime dateTime = new DateTime(parent, SWT.CALENDAR);
dateTime.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
Button button = new Button(parent, SWT.PUSH);
button.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
button.setText("Change date");
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
dateTime.setDay(1);// first day of month
dateTime.setMonth(1);// to february
// strange thing : we get the correct date that is just set, but gui is not ok.
System.out.println("new date:" + dateTime.getYear() + " " + dateTime.getMonth() + " " + dateTime.getDay());
}
});
dateTime.setYear(2017);
dateTime.setMonth(2);// march
dateTime.setDay(31);// last day of month
dateTime.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
System.out.println("selected:" + dateTime.getYear() + " " + dateTime.getMonth() + " " + dateTime.getDay());
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
System.out.println("def selected:" + dateTime.getYear() + " " + dateTime.getMonth() + " " + dateTime.getDay());
}
});
Kind regards,
Wim
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04560 seconds