Re[2]: java.util.Date

2002-11-06 Thread Rick Reumann


On Wednesday, November 6, 2002, 3:21:28 PM, Antoni wrote:


AR Keep in mind that DateFormat (and SimpleDateFormat) is not thread safe so you 
AR have to be very careful when reusing them. 
 
I like Max's suggestion though. I think I will move it to the
setFormatPattern for sure. Correct me if I'm wrong here...

Since the registration of this Converter takes places in a static
block in the top of my DispatchAction the setFormatPattern should
only be called once, since isn't only once instance of my
DispatchAction created (and thus only one initial load in the
static block?). I guess I could be extra careful and synchronize
setFormatPattern since I don't think that should incur too much
overhead since in my situation I can imagine more than one
instance of the Action class being created.



-- 

Rick
mailto:maillist;reumann.net


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




Re[2]: java.util.Date

2002-11-06 Thread Rick Reumann
On Wednesday, November 6, 2002, 4:47:32 PM, Eddie wrote:

EB static blocks are run with the class - right?  So it's really
EB irrelevant  how many instances get created - that code is run a
EB maximum of one time  - when the class is first loaded.

EB Am I wrong?

Right that's what I was thinking as well... I just didn't know of
the implications if the stuff was on multiple servers and all that
jazz (jazz that I know nothing about:)

-- 

Rick
mailto:maillist;reumann.net


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




Re: Re[2]: java.util.Date

2002-11-06 Thread Antoni Reus
Hi, I don't speak english very very well, so this is a bit difficult for me to 
explain, but I'll try ;-)  

see below ...

A Dimecres 06 Novembre 2002 21:37, Rick Reumann va escriure:
 On Wednesday, November 6, 2002, 3:21:28 PM, Antoni wrote:


 AR Keep in mind that DateFormat (and SimpleDateFormat) is not thread safe
 so you AR have to be very careful when reusing them.

 I like Max's suggestion though. I think I will move it to the
 setFormatPattern for sure. Correct me if I'm wrong here...

 Since the registration of this Converter takes places in a static
 block in the top of my DispatchAction the setFormatPattern should
 only be called once, since isn't only once instance of my
 DispatchAction created (and thus only one initial load in the
 static block?). I guess I could be extra careful and synchronize
 setFormatPattern since I don't think that should incur too much
 overhead since in my situation I can imagine more than one
 instance of the Action class being created.

I have'nt looked at the beanutils Converter registration, do you have to 
register a class or an instance?

The problem here is that if there is only one instance of your class, and 
setFormatPattern is only called once, then if there are two request that 
require the use of your class a the same time, served by different threads, 
the parse method in your instance of SimpleDateFormat might be called 
concurrently, so (as it isn't thread save) it might fail.





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




Re[2]: java.util.Date

2002-11-06 Thread Rick Reumann
On Wednesday, November 6, 2002, 6:51:22 PM, Wendy Smoak wrote:


WS Rick, thanks for posting this!  I almost missed it, but caught Max's reply.

WS You say that the default BeanUtils.copyProperties works fie with
WS java.sql.Date, but I find that I still have a problem unless the user types
WS in the date backwards-with-dashes (2002-11-06) the way the
WS java.sql.Date.valueOf() method wants it.  And that's a bit much to expect of
WS the users.

Sorry, just saw this post from you. Did you get it all worked out?
The DateConverter thing I mentioned works great when you register
like in the example and yes you have to BeanUtils.copyProperties.
You will be able to set the format for however you want the user
to enter it (11/06/02,etc) and it will display it back in the same
format. Just let me know if you got it worked out, if not I can
help.

--

Rick

mailto:maillist;reumann.net


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