The default date output in struts2 does not conform to our daily Chinese habits. The following are some of the methods I know to format the date output in struts2.
1. Use <s: date> for formatting, for example:
<S: date format = "yyyy-MM-dd"/> outputs the birthday attribute in the format of yyyy-MM-dd.
2. Use <s: param> for formatting, for example:
<S: textfield name = "mydate">
<S: param name = "value"> <s: date name = "mydate" format = "yyyy-MM-dd"/> </s: param>
</S: textfield>
Or <input type = "text" value = "<s: date format =" yyyy-MM-dd "/>"/>
3. Internationalization:
First, configure struts. custom. i18n. resources = globalMessages in struts. properties.
Add the following content to the globalMessages_zh_CN.properties and globalMessages_en_US.properties files:
Global. datetime = {0, date, yyyy-MM-dd HH: mm: ss}
Global. date = {0, date, yyyy-MM-dd}
Finally, you can use the following statement on the page to format and output the date:
<S: textfield name = "birthday" value = "% {getText ('Global. date', {birthday})}"/>
// Golbal. date Style
<S: textfield name = "birthday" value = "% {getText ('Global. datetime', {birthday})}"/>
// Global. datetime Style
We believe that the above three date formatting methods are sufficient to solve your problem.