How can I format the date list in struts 2 select tag?

I am trying to format dates in struts 2 select tag, but I am having difficulty with this. I know there is a struts 2 tag label, but I don't think this is what I am looking for.

What I am doing here fills the selection box with a list of dates (days off) where I can choose which dates to add to the employee’s time sheet. Basically I try to format them so that they appear nice and neat (MM / dd / yyyy), but I can't find the right way to do this. I tried inserting a format tag between my list below, I tried using the format.date parameter in the tag, and I tried using listValue to format dates, but nothing works. Did I miss something?

<s:select size="25" id="inputExclusionDates" name="available" list="availableExclusions" multiple="true" cssClass="multi-select" />

+2
source share
2

, , OGNL, , , - - .

, java.text.SimpleDateFormat, simpleDateFormat ( , , select, - listValue):

<s:select listValue="simpleDateFormat.format(new java.util.Date(#this[0].time))" size="25" id="inputExclusionDates" name="available" list="availableExclusions" multiple="true" cssClass="multi-select" />

, , JSP:

<s:select listValue="(new java.text.SimpleDateFormat('MM/dd/yyyy')).format(new java.util.Date(#this[0].time))" size="25" id="inputExclusionDates" name="available" list="availableExclusions" multiple="true" cssClass="multi-select" />

, , , , , new java.util.Date(#this[0].time), #this[0]. , . , : OGNL #this in s: select

+2

: " " "".

1 " "

public class MyDate {
  private Date date;

  public Date getDate(){
    return date;
  }

  public String getFormatedDate(){
    String str = **some code to format date**;
    return  str;
  }  

2 Exclusion

3

<s:select size="25" id="inputExclusionDates" name="available" list="availableExclusions" multiple="true" cssClass="multi-select" listKey="date" listValue="formatedDate"/>
+1

All Articles