简体   繁体   中英

Date other than current date in gwt date picker

I have a date field in which user could select dates from the datepicker in a particular date format. In view I am using this snippet which by default show current date selected in the datepicker.

this.dateFieldName.setFormat(new DateBox.DefaultFormat(DateTimeFormat
                .getFormat("dd-MM-yyyy")));

How do i modify the above code in gwt so that when user open the date picker, the default date selected should be 2 months from the current date.

You can add 2 months to java util date and set it to the dateField.

Date currentDate = new Date();
CalendarUtil.addMonthsToDate( currentDate, 2 );
dateFieldName.setValue( currentDate );

Hope this would help

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM