Posted on 2009-04-07 20:54
landor 閱讀(2114)
評(píng)論(0) 編輯 收藏 所屬分類:
struts2
可以在資源文件中定義日期及其數(shù)字的格式化,例如在classpath下新建一個(gè).properties文件,起名為format.properties,內(nèi)容如下
format.date = {0,date,dd-MM-yyyy}
{}里面的意思如下
{ 參數(shù)序號(hào)(從0開始), 格式類形(number | date | time | choice),
格式樣式(詳情請(qǐng)見http://java.sun.com/docs/books/tutorial/i18n/format
/decimalFormat.html#numberpattern)}
用<s:text>進(jìn)行引用
<s:i18n name="format">
<s:text name="format.date" >
<s:param value="user.birthday"></s:param>
</s:text>
</s:i18n>
后臺(tái)如果設(shè)置user.setBirthday(new Date());
前臺(tái)顯示:09-04-2009
在屬性文件中可以進(jìn)行數(shù)字等格式話
format.percent = {0,number,##0.00'%'}
format.money = {0,number,$##0.00}
參見帖子如下:
http://www.tkk7.com/keweibo/articles/174997.html