Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

format date inside a select item [duplicate]

Is there a way to format the date object to be displayed in a select item ?

Here's my example :

<h:selectOneMenu 
    label="Period" 
    value="#{myBean.periodStartEndList}"
    id="periodStartEnd" 
    converter="genericConverter">

    <f:selectItem itemLabel="Choose one .." noSelectionOption="true" />

    <f:selectItems 
        value="#{myBean.periodStartEndList}" 
        var="periodStartEnd"
        itemValue="#{periodStartEnd}" 
        itemLabel="#{periodStartEnd.map['dateStart']} -- #{periodStartEnd.map['dateEnd']}" />
</h:selectOneMenu>

And the combo / selection displays these :

Sun May 01 14:57:21 WIT 2011 -- Thu May 05 14:57:21 WIT 2011
Fri May 06 14:57:21 WIT 2011 -- Tue May 10 14:57:21 WIT 2011

I would like to have something simpler like :

01-05-2011 -- 05-05-2011
06-05-2011 -- 10-05-2011

I wonder how to achieve this ?

Thank you !

like image 590
Albert Gan Avatar asked Oct 12 '22 07:10

Albert Gan


1 Answers

You create EL function for conversion and use it. Check http://www.javabeat.net/tips/4-expression-language-in-jsp-20.html and http://wiki.apache.org/myfaces/Parameters_In_EL_Functions. Disclaimer: I never used it and don't know if it works.

like image 170
Adisesha Avatar answered Oct 29 '22 00:10

Adisesha