RE: Am I the only one using java.util.Date?

2002-10-16 Thread James Higginbotham

If you search the list archives at www.mail-archive.com, I think you
will find your question answered. Pappa Struts (Craig) answered it, as
did other folks. 

James

 -Original Message-
 From: Rick Reumann [mailto:[EMAIL PROTECTED]] 
 Sent: Wednesday, October 16, 2002 11:22 AM
 To: Struts List
 Subject: Am I the only one using java.util.Date?
 
 
 My business layer bean has a field as java.util.Date 
 (example: birthDate). My form bean uses the String for this 
 date (in this example.. String birthDate). The problem is I 
 can't seem to use BeanUtils to copy the properties since it 
 appears BeanUtils will only convert a java.sql.Date by default (get
 java.lang.IllegalArgumentException: argument type mismatch when using
 java.util.Date) . I tried dealing with registering a custom 
 Coverter I wrote and registering it with ConvertUtils and 
 below is a copy of the message I posted concerning this problem.
 
 I'm posting this question, though, because I'm curious how 
 others have dealt with this situation? Maybe using the 
 BeanUtils or PropertyUtils is not that common of a practice 
 or most use a java.sql.Date as opposed to java.util.Date? 
 Having dates in form fields is common so I'm curious how 
 others transfer their form field dates to their business 
 model (as java.util.Date?).
 
 Thanks for any info.
 
 Below was Converter question I posted last night, in case anyone is
 interested:
 
 I'm still having a bit of trouble trying to use BeanUtils to 
 copy java.util.Date properties. It appears that it will work 
 fine by default with java.sql.Date but isn't set up by 
 default for java.util.Date (which I'm using for Dates in my 
 business bean). I build a class implements Converter 
 interface and used the ConvertUtils to register 
 java.util.Date with this Converter. It works great converting 
 the String form properties to Dates as expected. The question 
 I have is how do I build a converter (or modify the existing
 one) that will convert the Date properties to String 
 properties when I want to go the other way with the 
 copyProperties (populate my DynaForm from a business bean)? I 
 tried modifying the covert method of the Converter I created 
 so that if the arg was a String property it would covert and 
 return a Date but the problem is this Converter never got 
 used when going the other direction (Date to String). Any 
 ideas what I'm doing wrong or what I can do to solve this problem?
 
 
 -- 
 
 Rick
 mailto:[EMAIL PROTECTED]
 
 
 --
 To unsubscribe, e-mail:   
 mailto:struts-user- [EMAIL PROTECTED]
 For 
 additional commands, 
 e-mail: mailto:[EMAIL PROTECTED]
 
 

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: Am I the only one using java.util.Date?

2002-10-16 Thread kiuma

Since I'm connected to jboss
I use java.sql.Date.

Then I pass values in millis and use a GregorianCalendar to manage dates.


Rick Reumann wrote:

My business layer bean has a field as java.util.Date (example:
birthDate). My form bean uses the String for this date (in this
example.. String birthDate). The problem is I can't seem to use
BeanUtils to copy the properties since it appears BeanUtils will only
convert a java.sql.Date by default (get
java.lang.IllegalArgumentException: argument type mismatch when using
java.util.Date) . I tried dealing with registering a custom Coverter I
wrote and registering it with ConvertUtils and below is a copy of the
message I posted concerning this problem.

I'm posting this question, though, because I'm curious how others have
dealt with this situation? Maybe using the BeanUtils or PropertyUtils
is not that common of a practice or most use a java.sql.Date as
opposed to java.util.Date? Having dates in form fields is common so
I'm curious how others transfer their form field dates to their
business model (as java.util.Date?).

Thanks for any info.

Below was Converter question I posted last night, in case anyone is
interested:

I'm still having a bit of trouble trying to use BeanUtils to copy
java.util.Date properties. It appears that it will work fine by
default with java.sql.Date but isn't set up by default for
java.util.Date (which I'm using for Dates in my business bean). I
build a class implements Converter interface and used the ConvertUtils
to register java.util.Date with this Converter. It works great
converting the String form properties to Dates as expected. The
question I have is how do I build a converter (or modify the existing
one) that will convert the Date properties to String properties when I
want to go the other way with the copyProperties (populate my DynaForm
from a business bean)? I tried modifying the covert method of the
Converter I created so that if the arg was a String property it would
covert and return a Date but the problem is this Converter never got
used when going the other direction (Date to String). Any ideas what
I'm doing wrong or what I can do to solve this problem?





--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: Am I the only one using java.util.Date?

2002-10-16 Thread du Plessis, Corneil C

When you input or output dates you should java.text.SimpleDateFormat format
and parse functions to convert to and from a known format string like
-MM-dd that you can maintain in a ResourceBundle.

Tell the user which format you expect by rendering todays date with the
format string.

Corneil du Plessis
Technical Specialist
Internet Development
Retail Channels
Standard Bank
Direct +27 (11) 636-2210
Mobile +27 (83) 442-9221
ICQ# 66747137



-Original Message-
From: Rick Reumann [mailto:[EMAIL PROTECTED]]
Sent: 16 October, 2002 18:22
To: Struts List
Subject: Am I the only one using java.util.Date?


My business layer bean has a field as java.util.Date (example:
birthDate). My form bean uses the String for this date (in this
example.. String birthDate). The problem is I can't seem to use
BeanUtils to copy the properties since it appears BeanUtils will only
convert a java.sql.Date by default (get
java.lang.IllegalArgumentException: argument type mismatch when using
java.util.Date) . I tried dealing with registering a custom Coverter I
wrote and registering it with ConvertUtils and below is a copy of the
message I posted concerning this problem.

I'm posting this question, though, because I'm curious how others have
dealt with this situation? Maybe using the BeanUtils or PropertyUtils
is not that common of a practice or most use a java.sql.Date as
opposed to java.util.Date? Having dates in form fields is common so
I'm curious how others transfer their form field dates to their
business model (as java.util.Date?).

Thanks for any info.

Below was Converter question I posted last night, in case anyone is
interested:

I'm still having a bit of trouble trying to use BeanUtils to copy
java.util.Date properties. It appears that it will work fine by
default with java.sql.Date but isn't set up by default for
java.util.Date (which I'm using for Dates in my business bean). I
build a class implements Converter interface and used the ConvertUtils
to register java.util.Date with this Converter. It works great
converting the String form properties to Dates as expected. The
question I have is how do I build a converter (or modify the existing
one) that will convert the Date properties to String properties when I
want to go the other way with the copyProperties (populate my DynaForm
from a business bean)? I tried modifying the covert method of the
Converter I created so that if the arg was a String property it would
covert and return a Date but the problem is this Converter never got
used when going the other direction (Date to String). Any ideas what
I'm doing wrong or what I can do to solve this problem?


-- 

Rick
mailto:[EMAIL PROTECTED]


--
To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
For additional commands, e-mail:
mailto:[EMAIL PROTECTED]

__

Disclaimer and confidentiality note


Everything in this e-mail and any attachments relating to the official business of 
Standard Bank Group Limited is proprietary to the company. It is confidential, legally 
privileged and protected by law. Standard Bank does not own and endorse any other 
content. 
Views and opinions are those of the sender unless clearly stated as being that of 
Standard Bank. 

The person addressed in the e-mail is the sole authorised recipient. Please notify the 
sender 
immediately if it has unintentionally reached you and do not read, disclose or use the 
content
in any way. 

Standard Bank can not assure that the integrity of this communication has been 
maintained nor 
that it is free of errors, virus, interception or interference.

__

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: Am I the only one using java.util.Date?

2002-10-16 Thread Brian Hickey

Rick,

You are on the right track. A suggestion would be to break the month, day
and year out on your forms (makes nice-nice with html:select) and provide
the code to populate them in your form instance. The conversion is actually
quite simple:

public GregorianCalendar getStartDate()
{
  return new GregorianCalendar( this.getStartYear(), this.getStartMonth()-1,
this.getStartDay() );
}

This getter (exists in the same form instance) will hand off the startDate
as a java.util.Date to your (dyn)Action.

HTH

Brian

- Original Message -
From: Rick Reumann [EMAIL PROTECTED]
To: Struts List [EMAIL PROTECTED]
Sent: Wednesday, October 16, 2002 12:22 PM
Subject: Am I the only one using java.util.Date?


 My business layer bean has a field as java.util.Date (example:
 birthDate). My form bean uses the String for this date (in this
 example.. String birthDate). The problem is I can't seem to use
 BeanUtils to copy the properties since it appears BeanUtils will only
 convert a java.sql.Date by default (get
 java.lang.IllegalArgumentException: argument type mismatch when using
 java.util.Date) . I tried dealing with registering a custom Coverter I
 wrote and registering it with ConvertUtils and below is a copy of the
 message I posted concerning this problem.

 I'm posting this question, though, because I'm curious how others have
 dealt with this situation? Maybe using the BeanUtils or PropertyUtils
 is not that common of a practice or most use a java.sql.Date as
 opposed to java.util.Date? Having dates in form fields is common so
 I'm curious how others transfer their form field dates to their
 business model (as java.util.Date?).

 Thanks for any info.




--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: Am I the only one using java.util.Date?

2002-10-16 Thread Padma Ginnaram

If you are using struts 1.1 and validator framework,
StrutsValidator.validateDate converts the string to a java.util.Date and
returns this Date. This returned value gets saved on the validationResults
in the ValidatorForm.

ValidatorForm.getResultValueMap() returns a HashMap containing these
converted values associated to each form property that is being
validated/translated.

I am not using 1.1 yet, but used the same approach in 1.0 by extending
struts validator framework to do my form property conversion. 

-Padma

-Original Message-
From: Rick Reumann [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, October 16, 2002 12:22 PM
To: Struts List
Subject: Am I the only one using java.util.Date?


My business layer bean has a field as java.util.Date (example:
birthDate). My form bean uses the String for this date (in this
example.. String birthDate). The problem is I can't seem to use
BeanUtils to copy the properties since it appears BeanUtils will only
convert a java.sql.Date by default (get
java.lang.IllegalArgumentException: argument type mismatch when using
java.util.Date) . I tried dealing with registering a custom Coverter I
wrote and registering it with ConvertUtils and below is a copy of the
message I posted concerning this problem.

I'm posting this question, though, because I'm curious how others have
dealt with this situation? Maybe using the BeanUtils or PropertyUtils
is not that common of a practice or most use a java.sql.Date as
opposed to java.util.Date? Having dates in form fields is common so
I'm curious how others transfer their form field dates to their
business model (as java.util.Date?).

Thanks for any info.

Below was Converter question I posted last night, in case anyone is
interested:

I'm still having a bit of trouble trying to use BeanUtils to copy
java.util.Date properties. It appears that it will work fine by
default with java.sql.Date but isn't set up by default for
java.util.Date (which I'm using for Dates in my business bean). I
build a class implements Converter interface and used the ConvertUtils
to register java.util.Date with this Converter. It works great
converting the String form properties to Dates as expected. The
question I have is how do I build a converter (or modify the existing
one) that will convert the Date properties to String properties when I
want to go the other way with the copyProperties (populate my DynaForm
from a business bean)? I tried modifying the covert method of the
Converter I created so that if the arg was a String property it would
covert and return a Date but the problem is this Converter never got
used when going the other direction (Date to String). Any ideas what
I'm doing wrong or what I can do to solve this problem?


-- 

Rick
mailto:[EMAIL PROTECTED]


--
To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
For additional commands, e-mail:
mailto:[EMAIL PROTECTED]

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]