Why is my List<Date> not getting converted? The <p:selectOneMenu> items pattern looks like
Thu Mar 01 00:00:00 BRT 2012 instead of the desired “MM/yyyy”.
<p:selectOneMenu value="#{report003.selectedMes}">
<p:ajax update="pesquisaThomas" listener="#{report003.loadPesquisa()}" />
<f:selectItem itemLabel="[Todos]" itemValue="" />
<f:convertDateTime pattern="MM/yyyy" />
<f:selectItems value="#{report003.pesquisaMeses}" />
</p:selectOneMenu>
The conversion applies to the item value only, not to the item label. The label is just presented using the default
Date#toString()pattern.Your best bet is either creating a
List<SelectItem>instead ofList<Date>wherein you convert the item labels yourself,or using
<f:selectItems var>with an EL function in theitemValue. For example, the OmniFacesof:formatDate()(or homegrow one).This problem is by the way not specific to
<p:selectOneMenu>, you would have exactly the same problem when using the standard<h:selectOneMenu>.