Smartgwt组件的默认日历小部件显示日期为Sun 10/31(MM / DD格式)。
http://www.smartclient.com/smartgwt/showcase/#simple_calendar_category
如何在Calendar Widget中将日期格式更改为DD / MM格式?
先谢谢你看看, 萨钦
答案 0 :(得分:2)
SmartGwt提供了一个静态DateUtil来更改日期格式。在应用程序的某处放置以下代码,它将在整个应用程序中更改日期格式
DateUtil.setShortDateDisplayFormatter(new DateDisplayFormatter() {
public String format(Date date) {
if(date == null) return null;
final DateTimeFormat dateFormatter = DateTimeFormat.getFormat("DD/MM/yyyy");
String format = dateFormatter.format(date);
return format;
}
});
答案 1 :(得分:1)
专门查看com.smartgwt.client.util.DateUtil
方法setShortDateDisplayFormat
和setShortDateDisplayFormatter
这可以解决您的问题,根据文档。
答案 2 :(得分:0)
把
this.setDateFormatter(DateDisplayFormat.TOEUROPEANSHORTDATE);
构造函数中的
答案 3 :(得分:0)
@aruns是正确的,但如果您使用RelativeDateItem
,则需要采取另一个步骤 DateUtil.setShortDatetimeDisplayFormatter(new DateDisplayFormatter()
{
public String format(Date date)
{
if(date == null)
{
return null;
}
else
{
final DateTimeFormat dateFormatter = DateTimeFormat.getFormat(DATE_FORMAT);
return dateFormatter.format(date);
}
}
});
DateUtil.setDateParser(new DateParser()
{
public Date parse(String dateString)
{
final DateTimeFormat format = DateTimeFormat.getFormat(DATE_FORMAT);
return format.parse(dateString);
}
});
DateFormat在GWT文档中定义