I have retrieve the Order table form database using hibernate criteria option. In my hbm there is class Order.java in this class there is a variable
private Date createdAt;
like this
and here is my getter and setter like this
public Date getCreatedAt() {
return this.createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
and in my action page i have tried to set the values in createdAt field in different format
like this
DateFormat formatter ;
Date date ;
formatter = new SimpleDateFormat("dd-MMM");
Iterator it = salesDetails.iterator();
while(it.hasNext()){
Order o=(Order) it.next();
date = (Date)formatter.parse("22-June");
o.setCreatedAt(date);
System.out.println(o.getCreatedAt());
}
But i cannot insert data in this format into this variable as createdAt is a Date variable. But i need to get the data in “date-month” format. I don’t want to display the year there.
How is it possible. Is it possible to get data like this using this createdAt variable?
If you want to format date inside your jsp page there are lots of way to achieve this one such way is to use Struts2 build formatting feature
refer this official page for details
formatting-dates-and-numbers
Alternatively best way to use Struts2 date tag for more details refer this page.
Struts2 Date Tag