0

I'm using af:inputDate in my form.

in my backing bean i'm trying to get the value as Date object.

public RichInputDate getFromDate() {
return fromDate;
}

public void convert(){
Date fromDt = (Date)this.getFromDate().getValue(); 
}

but I get this error: java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Date any idea? is there a simple way to get the value as Date object.

Thanks!

4

2 回答 2

0

是的,有: http ://www.roseindia.net/java/java-conversion/StringToDate.shtml

使用它也更安全

<af:convertDateTime pattern="yyyy/M/d" secondaryPattern="d/M/yyyy" />

在您的输入组件中,因此您确定它使用的是正确的模式。

于 2012-11-22T11:23:07.753 回答
0

谈到 ADF,有:

private RichInputDate invoiceDate;

我们可以这样做:

String s2 = invoiceDate.getValue().toString();

为了以字符串格式获取日期。这将帮助您以字符串格式获取它,然后您可以将其转换为 Date 对象。

问候,

于 2014-12-02T00:04:26.523 回答