---
title: "struts2中日期转换问题"
author: "karvenlin"
date: "2010-08-09T13:34:45Z"
tags: []
categories: ["企业架构"]
slug: "struts2"
draft: false
lastmod: "2010-08-09T13:41:26Z"
id: 732846
url: "https://karvenlin.iteye.com/blog/732846"
---

通过struts2的Action从数据库中查找出了一个USER列表，List<User>，User属性中有日期类型，但是却表示成为int，比如属性int startDate为20100806，在页面迭代这个列表显示，但是要显示startDate时却要表示为日期类型，2010-08-06，请问各位我如何实现？急！！！！！急！！！！！
（
s:date标签使用时，一定要是Date类型。String型，数值型等其他类型，可以用以下方法：先在resource文件中定义如下：format.date_medium={0,date,medium}format.date_ymd={0,date,yyyy/MM/dd}format.date_time={0,date,yyyy/MM/dd hh:mm}format.number_money={0,number,#,##0}然后就可以自由的format了：<s:text name="format.number_money"> <s:param name="value" value="salesPrice"/></s:text>円<s:text name="format.date_ymd"> <s:param name="value" value="salesDate"/></s:text> 
）这种方式行不通