我有一个日期字段,用户可以在特定日期格式中从日期选择器中选择日期。在视图中我使用此片段,默认情况下显示在datepicker中选择的当前日期。
this.dateFieldName.setFormat(new DateBox.DefaultFormat(DateTimeFormat
.getFormat("dd-MM-yyyy")));
如何在gwt中修改上述代码,以便在用户打开日期选择器时,所选的默认日期应该是当前日期的2个月。
答案 0 :(得分:2)
您可以将2个月添加到java util date并将其设置为dateField。
Date currentDate = new Date();
CalendarUtil.addMonthsToDate( currentDate, 2 );
dateFieldName.setValue( currentDate );
希望这会有所帮助