首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 ><rich:calendar>不接受java.util.Calendar

<rich:calendar>不接受java.util.Calendar
EN

Stack Overflow用户
提问于 2011-06-17 15:18:24
回答 1查看 2.3K关注 0票数 2

我正在尝试使用rich:calendar,当日期属性selectedDatecurrentDateDate类型时,它可以工作。当我使用Calendar时,它不起作用。

当我提交一份表格时,它会报告:

代码语言:javascript
复制
SEVERE: Servlet.service() for servlet [Faces Servlet] in context with path [/PORTAL] threw exception [javax.el.ELException: /test.xhtml @58,36 value="#{bean.calendar.selectedDate}": Cannot convert 24.6.11 0:00 of type class java.util.Date to class java.util.Calendar] with root cause
javax.el.ELException: /test.xhtml @58,36 value="#{bean.calendar.selectedDate}": Cannot convert 24.6.11 0:00 of type class java.util.Date to class java.util.Calendar

我的XHTML

代码语言:javascript
复制
<rich:calendar 
  mode="ajax" id="calendar"
  value="#{bean.calendar.selectedDate}"  
  locale="#{calendarBean.locale}"  
  datePattern="#{calendarBean.pattern}"                        
  required="true">                   
</rich:calendar>

和日历bean

代码语言:javascript
复制
@ManagedBean
public class CalendarBean
{    
  private Calendar currentDate;  
  private Calendar selectedDate;

  public Calendar getCurrentDate() {  
    return currentDate;  
  }  
  public void setCurrentDate(Calendar currentDate) {  
    this.currentDate = currentDate;  
  } 
  public Calendar getSelectedDate() { 
    return selectedDate;  
  }  
  public void setSelectedDate(Calendar selectedDate) {  
    this.selectedDate = selectedDate;  
  }

我做错什么了?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-06-17 15:22:26

Calendar类具有一个time属性,该属性表示一个java.util.Date,包含一个吸气剂塞特。好好利用它。

代码语言:javascript
复制
value="#{bean.calendar.selectedDate.time}"  
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6387966

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档