nijogeorgep / smartgwt

Automatically exported from code.google.com/p/smartgwt
0 stars 0 forks source link

getValue() for TimeItem returns tomorrow's date for a time smaller than 02:00:00 #579

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
public void onModuleLoad() {  

        test();

    }   

        private void test() {
            VLayout vLayout = new VLayout(10);
            final TimeItem time1 = new TimeItem("time1");
            time1.setUseMask(true);
            time1.setDefaultValue("00:00");
            final TimeItem time2 = new TimeItem("time2");
            time2.setUseMask(true);
            time2.setDefaultValue("00:00");
            ButtonItem getTimeButton = new ButtonItem("getTimeButton", "Get Time");
            getTimeButton.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {
                    Date date1 = (Date)time1.getValue();
                    Date date2 = (Date)time2.getValue();
                    SC.say(date1 + " - " + date2);

                }
            });

            DynamicForm timeForm = new DynamicForm();
            timeForm.setFields(time1, time2, getTimeButton);

            vLayout.addMember(timeForm);

            vLayout.draw();

    }

What steps will reproduce the problem?
1.Enter 01:59 for time1
2.Enter 02:00 for time2
3.Click "Get Date" button

What is the expected output? What do you see instead?
Expected - Thu Apr 27 01:59:00 CEST 2011 - Wed Apr 27 02:00:00 CEST 2011
Actual   - Thu Apr 28 01:59:00 CEST 2011 - Wed Apr 27 02:00:00 CEST 2011

What version of the product are you using? On what operating system?
Smart GWT 2.4, GWT 2.0.3, Windows 7 Ultimate, Explorer 8

Please provide any additional information below.
This is causing my DateRangeValidator to fail

Original issue reported on code.google.com by alessand...@gmail.com on 27 Apr 2011 at 12:48

Attachments:

GoogleCodeExporter commented 8 years ago
With a time value, the year/month/day are meaningless and intended to be 
ignored.  This means you can't use a "dateRange" validator with a time value 
because a dateRange validator takes the year/month/day into account.  In this 
case use a custom validator - a "timeRange" validator will eventually be 
provided so you don't have to write a custom validator for this case.

Original comment by smartgwt...@gmail.com on 27 Apr 2011 at 1:51

GoogleCodeExporter commented 8 years ago
Thank you!
I agree with your explanation on the use of validators.
I think my problems are related to getValue() of TimeItem about expected output 
and not to custom validator.

Original comment by alessand...@gmail.com on 27 Apr 2011 at 2:16

GoogleCodeExporter commented 8 years ago
Once again: for time values, year/month/day are meaningless and should be 
ignored.

Original comment by smartgwt...@gmail.com on 27 Apr 2011 at 2:19