2012-07-11 63 views
0

使用rich:calendar時出現問題:選擇該值後,我將該值設置爲日曆類型的bean。在豆它顯示一個錯誤,並且日期值時,會出現隨着我們怎麼能得到的只有時間價值沒有得到時間獲取日期而沒有選定值的時間豐富:日曆

這裏的時間是我寫的代碼:

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

的錯誤消息指出:

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'. 

當我在主頁面設置的值2012,11,07,我得到的值'7/11/12
12:00 AM'
一個額外的12:00 AM

我怎樣才能得到日期值?

回答

1

您看到的值爲'7/11/12 12:00 AM'的消息沒有錯,它只是由rich:calendar創建的對象日期的.toString()方法的結果。

您應該檢查類com.customer.types.Information(其中來自消息,看起來屬於editCustomerBean.person.demographic屬性的類型)實際上是否有適當的setDateOfBirth(Date dt)方法。然後,相應地修復您的代碼(指向適當的屬性或創建適當的setter)。

+0

感謝eljunior爲你的回覆我有適當的getters和setters,出生日期是類型日曆。我認爲它只接受日期,而不是time.So我可以得到只有日期,但不是時間12:00Am – satish 2012-07-12 05:18:40

+0

我用轉換器它解決了這個問題... – satish 2012-07-12 05:49:18

+0

哦,沒事!很高興你解決了它,然後! :) – elias 2012-07-12 12:16:40