The default date output operations in Oracle struts2 do not match our Chinese daily output habits. the following describes how to correctly format the date output in struts2. We hope you will have a better understanding of the default date output in Oracle struts2.
1. Use <s: date> for formatting. For example:
<S: date name = "birthday" format = "yyyy-MM-dd"/> outputs the attribute birthday in the format of yyyy-MM-dd.
2. Use <s: param> to format the file. For example:
- <s:textfield name="birthday" >
- <s:param name="value"><s:date name="birthday" format="yyyy-MM-dd"/></s:param>
- </s:textfield>
Or <input type = "text" value = "<s: date name =" birthday "format =" yyyy-MM-dd "/>"/>
Another method is to internationalize:
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
The above content is a description of the display problem of the date input in Oracle struts2, hoping to help you in this aspect.