简体   繁体   中英

Get the date without the time of the selected value in rich:calendar

I got a problem when using rich:calendar : after selecting the value, I am setting the value in the bean of type Calendar. In the bean it is showing an error and the date value is appeared along with the time so how can we get only date value without getting the time

Here is the code I have written:

<rich:calendar value="#{editCustomerBean.person.demographic.dateOfBirth}"
  cellWidth="15px" cellHeight="22px" style="width:200px"
  datePattern="yyyy,dd,MM"/>  

The error message says:

SEVERE: //C:/Workspace/Kumar/WebContent/satish/Main.xhtml @71,268 
value="#{editCustomerBean.person.demographic.dateOfBirth}":   
Can't set property 'dateOfBirth' on   
class 'com.customer.types.Information' to value '7/11/12   
12:00   AM'. 

When I set the value 2012,11,07 in the main page, I get the value '7/11/12
12:00 AM'
'7/11/12
12:00 AM'
'7/11/12
12:00 AM'
with an extra 12:00 AM .

How can I get only the date value?

The message you are seeing with the value '7/11/12 12:00 AM' is not wrong, it is just the result of the .toString() method of the object date create by rich:calendar .

You should check if the class com.customer.types.Information (which from the message, it seems that is the type of the editCustomerBean.person.demographic property) actually has the appropriate setDateOfBirth(Date dt) method. Then, fix your code accordingly (pointing to the proper property or creating the adequate setter).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM