Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8593429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:59:12+00:00 2026-06-11T23:59:12+00:00

Why is my List<Date> not getting converted? The <p:selectOneMenu> items pattern looks like Thu

  • 0

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>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T23:59:14+00:00Added an answer on June 11, 2026 at 11:59 pm

    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 of List<Date> wherein you convert the item labels yourself,

    List<Date> availableDates = ...;
    List<SelectItem> selectItems = ...;
    SimpleDateFormat sdf = new SimpleDateFormat("MM/yyyy");
    
    for (Date availableDate : availableDates) {
        selectItems.add(new SelectItem(availableDate, sdf.format(availableDate)));
    }
    

    or using <f:selectItems var> with an EL function in the itemValue. For example, the OmniFaces of:formatDate() (or homegrow one).

    <f:selectItems value="#{bean.availableDates}" var="date" 
        itemValue="#{date}" itemLabel="#{of:formatDate(date, 'MM/yyyy')}" />
    

    This problem is by the way not specific to <p:selectOneMenu>, you would have exactly the same problem when using the standard <h:selectOneMenu>.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting from database list of items ordered by descending date. I use
My class objects are not getting converted into json, I think it returns object
How to sort list of date object ? For example I have unsorted list
I'm creating an app that should list the date and time when a button
I'm trying to list a few date ranges based off the last Tuesday which
How to get the friends list by the date they added? Or How long
Having a date reference UserJoinDate and the list of dates List friendsJoined I would
I have a long list of files that all end in a date in
I have a list of objects called Activity: class Activity { public Date activityDate;
How to list files in a directory in last modified date order? (PHP5 on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.