I am creating a website using struts2,mysql,hibernate(for table to class mapping)
In Mysql value stored is
2012-12-10 00:04:52
After fetching it to a variable “addedDate” i tried printing it
class d{
Date addedDate;
}
addedDate is 2012-12-10 00:04:52.0
In Hibernate mapping (xml file) i have given
<property name="addedDate" type="timestamp">
<column name="ADDED_DATE" length="19" not-null="true" />
</property>
In the Action class i have created
List<d> dList
in jsp
<s:iterator value="dList" >
<td><s:property value="addedDate" /></td>
</s:iterator>
The output i get on the screen
12/10/12 12:04:52 AM.000
I want to remove the “.000” in my outtput any suggestions please
i tried changing type hibernate xml file to Date 1st then to time. Each time its giving only time or date but i want both without milliseconds.
1 way would be to create a string variable in class d copy addedate to that string then do modification and show on jsp. In that case i don’t know to convert from 24hr to 12 hr format
please suggest me if there is any other way or if u need any clarifications do ask me.Thanks in advance
Take a look at the
datetag.Sample from the doc (adapted):
(not tested)