struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ashish Kulkarni <kulkarni_ash1...@yahoo.com>
Subject Re: java.util.Date vs java.sql.Timestamp
Date Tue, 22 Feb 2005 19:58:44 GMT
Hi
I would read the property as a String and then use
SimpleDateFormat to convert it to time stamp, i am not
sure if this conversion is done automatically in bean
public setMyDate(String myDateString)
 {
//i dont remmember the date format
try
{
SimpleDateFormat format = new SimpleDateFormat();
java.sql.Timestamp myDate =
format.parse(myDateString);
this.myDate = myDate;
}
catch(Exception exc)
{
}
	
   }
--- Mark Bennett <mark.bennett@ncmail.net> wrote:

> How can I have struts put a java.util.Date object
> into a Bean?
> 
> I have found that I can set a Timestamp object into
> a bean.  THIS DOES WORK
> (below).  However, if I change the type on the bean
> to java.util.Date then I
> get a stack trace (also below).  I've also tried
> different formatting like:
> value="Sat Jan 01 00:00:00 EST 2005".  Any hints? 
> Thanks.
> 
> Mark
> 
> 
> class MyBean {
>   private java.sql.Timestamp myDate;
> 
>   public setMyDate(java.sql.Timestamp myDate) {
> 	this.myDate = myDate;
>   }
> }
> 
> <input type="hidden" name="myDate" value="2005-01-01
> 00:00:00.0">
> 
> 
> 
> 
> 
> java.lang.IllegalArgumentException: argument type
> mismatch
> 	at java.lang.reflect.Method.invoke(Native Method)
> 	at
>
org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyUtils.j
> ava:1789)
> 	at
>
org.apache.commons.beanutils.PropertyUtils.setNestedProperty(PropertyUtils.j
> ava:1684)
> 	at
>
org.apache.commons.beanutils.PropertyUtils.setProperty(PropertyUtils.java:17
> 13)
> 	at
>
org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:1019)
> 	at
>
org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)
> 	at
>
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1252)
> 	at
>
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.j
> ava:821)
> 	at
>
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)
> 	at
>
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
> 	at
>
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
> 	at
>
javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
> 	at
>
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> 	at
>
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
> :263)
> 	at
>
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
> :200)
> 	at
>
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
> ntext.java:2390)
> 	at
>
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
> :1959)
> 	at
>
weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
> 	at
>
weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
> 
> 



		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - Helps protect you from nasty viruses. 
http://promotions.yahoo.com/new_mail

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message