struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Søren Blidorf <so...@nolas.dk>
Subject SV: date format problems
Date Fri, 07 Mar 2003 00:07:05 GMT
That did it, Thanks a million.

It looks almost like what I did, but I found my mistake.

-----Oprindelig meddelelse-----
Fra: Michael Cardon [mailto:mic@bendcable.com] 
Sendt: 7. marts 2003 00:50
Til: Struts Users Mailing List
Emne: RE: date format problems

Here is what I do. The client enters a date of birth date as a string on
the
form, then I convert it to a java.sql.Date object in this method.


	/**
	 * Sets the dobStr
	 * @param dobStr The dobStr to set
	 */
	public void setDobStr(String dobStr) throws
java.text.ParseException {
		this.dobStr = dobStr;

		// reset the Date object
		this.dobDate = null;

		if ((dobStr != null) && (dobStr.length() > 0)) {
			SimpleDateFormat sdf = new
SimpleDateFormat("MM/dd/yy");
			sdf.setLenient(false);

			try {
				java.util.Date dt = sdf.parse(dobStr);
				this.dobDate = new
java.sql.Date(dt.getTime());

			} catch (ParseException pe) {
				throw new java.text.ParseException("Date
Of Birth:",
pe.getErrorOffset());
			}
		}
	}

-----Original Message-----
From: Søren Blidorf [mailto:soren@nolas.dk]
Sent: Thursday, March 06, 2003 3:42 PM
To: 'Struts Users Mailing List'
Subject: SV: date format problems


Hi.
Thanks for all the answers

I was trying different things because nothing would work for me.

I need one thing:

Convert the String value theForm.GetMyDate() so that I can insert it in
my sql as yyyy-MM-dd.

I get the error java.lang.IllegalArgumentException: Cannot format given
Object as a Date

I will look at BeanUtils.copyProperties( beanToCopyTo, beanCopyingFrom
);, but it is probably to complicated for me just now!

What is the best way to fix it?

-----Oprindelig meddelelse-----
Fra: Chen, Gin [mailto:Gin.Chen@NielsenMedia.com]
Sendt: 6. marts 2003 16:31
Til: 'Struts Users Mailing List'
Emne: RE: date format problems

The "standard" for an actionForm is to have every field as String.
All conversion (which should really be thought of as business logic)
should
occur in the Action classes or further down the food chain. If this is
not
possible in your case or does not solve what your working on then can
you
please give more details?
-Tim


-----Original Message-----
From: Kandi Potter [mailto:Kandi.Potter@PWGSC.GC.CA]
Sent: Thursday, March 06, 2003 10:21 AM
To: Struts Users Mailing List
Subject: RE: date format problems


I'm no expert at struts but I  convert and validate my dates in my
Action or
Business Class instead of the Form.  I could be completely off-base here
in
my interpretation of the struts ActionForm though........

-----Original Message-----
From: Søren Blidorf [mailto:soren@nolas.dk]
Sent: Thursday, March 06, 2003 10:07 AM
To: struts-user@jakarta.apache.org
Subject: date format problems


Hi.

I have an action that gets a date from the MS SQL 2000 in yyyy-MM-dd. I
convert it with simpledateformat as dd-MM-yyyy and put it in a jsp form.
When submitting the form the date must be coverted back to yyyy-MM-DD
before another actions update the db.

I am trying to convert the date value in the ActionForm, but I am
getting the following error.

Any idears? I am lost and it is very urgent

Søren Blidorf


HTTP Status 500 -

------------------------------------------------------------------------
--------

type Exception report

message

description The server encountered an internal error () that prevented
it from fulfilling this request.

exception

javax.servlet.ServletException: BeanUtils.populate
	at
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:774)
	at
org.apache.struts.action.ActionServlet.processPopulate(ActionServlet.jav
a:2061)
	at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1564)
	at
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:510)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
tionFilterChain.java:247)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
erChain.java:193)
	at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValv
e.java:260)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:643)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4
80)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValv
e.java:191)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:643)
	at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authenticator
Base.java:550)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:641)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4
80)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:241
5)
	at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java
:180)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:643)
	at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherVa
lve.java:170)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:641)
	at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java
:172)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:641)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4
80)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.
java:174)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:643)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4
80)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
	at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:43
2)
	at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processC
onnection(Http11Protocol.java:386)
	at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:53
4)
	at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool
.java:530)
	at java.lang.Thread.run(Thread.java:536)


root cause

java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:324)
	at
org.apache.struts.util.PropertyUtils.setSimpleProperty(PropertyUtils.jav
a:988)
	at
org.apache.struts.util.PropertyUtils.setNestedProperty(PropertyUtils.jav
a:904)
	at
org.apache.struts.util.PropertyUtils.setProperty(PropertyUtils.java:932)
	at org.apache.struts.util.BeanUtils.populate(BeanUtils.java:509)
	at
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:772)
	at
org.apache.struts.action.ActionServlet.processPopulate(ActionServlet.jav
a:2061)
	at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1564)
	at
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:510)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
tionFilterChain.java:247)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
erChain.java:193)
	at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValv
e.java:260)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:643)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4
80)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValv
e.java:191)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:643)
	at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authenticator
Base.java:550)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:641)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4
80)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:241
5)
	at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java
:180)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:643)
	at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherVa
lve.java:170)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:641)
	at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java
:172)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:641)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4
80)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.
java:174)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:643)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4
80)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
	at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:43
2)
	at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processC
onnection(Http11Protocol.java:386)
	at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:53
4)
	at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool
.java:530)
	at java.lang.Thread.run(Thread.java:536)
Caused by: java.lang.IllegalArgumentException
	at java.util.Date.parse(Date.java:582)
	at java.util.Date.(Date.java:264)
	at um.forms.SikForm.setB_sag(SikForm.java:49)
	... 45 more



------------------------------------------------------------------------
--------

Apache Tomcat/4.1.18



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



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

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



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


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



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


Mime
View raw message