I wonder if Sun is willing to make another twist to this convoluted date/format situation given the fact that this has had enough twists in the past already. Yet if another one yields good result, I'd vote for it.
-James
From: Greg Nudelman <[EMAIL PROTECTED]>
Reply-To: "JDJList" <[EMAIL PROTECTED]>
To: "JDJList" <[EMAIL PROTECTED]>
Subject: [jdjlist] RE: Using SimpleDateFormat
Date: Thu, 30 Jan 2003 11:24:35 -0800
I am going to go out on the limb and say that I would create a new formatter
inside the method, unless you're expecting to be routinely processing a
10,000 date object Vector. SimpleDateFormat should be fairly small.
Alternatively, if you only got a couple of formats, you can easily write
your own optimized thread-safe custom parser, and use Calendar class to
create the Date object (or just use Calendar throughout). I had to do this
for the GMT date in the XML documents, as Sun was not forthcoming enough to
write the W3C standard date format parser into their DateFormat. Imagine
that!
We had no problems with this model for 6 months now in production.
Greg
-----Original Message-----
From: Kamyar Varzandeh [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 29, 2003 10:59 PM
To: JDJList
Subject: [jdjlist] RE: Using SimpleDateFormat
Thank you all for your help. I have a follow-up question. From performance
perspective, is it better to synchronize the methods (and use an instance
variable formatter), or to create the formatter inside each method?
Thanks in advance.
Rich Gibbs <[EMAIL PROTECTED]> wrote:
The SimpleDateFormat, and its underlying methods are not threadsafe.
-----Original Message-----
From: Kamyar Varzandeh [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 29, 2003 10:35 AM
To: JDJList
Subject: [jdjlist] Using SimpleDateFormat
Hi:
Are there any issues with using SimpleDateFormat as a static instance
variable and then using it in all the methods as in
public class DateUtil {
public static final String MMDDYYYYFormat = "MM/dd/yyyy";
public static final SimpleDateFormat sdf_MMDDYYYY = new
SimpleDateFormat(MMDDYYYYFormat);
public static Date toDate(String dateStr) throws ParseException {
return sdf_MMDDYYYY.parse(dateStr);
}
We have started getting NumberFormatException when invalid data is passed
in. We did not get such exceptions before when we had defined the formatter
inside the method. Any ideas?
_____
Do you Yahoo!?
Yahoo! <http://rd.yahoo.com/mail/mailsig/*http://mailplus.yahoo.com> Mail
Plus - Powerful. Affordable. Sign up
<http://rd.yahoo.com/mail/mailsig/*http://mailplus.yahoo.com> now
____________________________________________________ To change your JDJList
options, please visit: http://www.sys-con.com/java/list.cfm Be respectful!
Clean up your posts before replying
____________________________________________________
____________________________________________________
To change your JDJList options, please visit:
http://www.sys-con.com/java/list.cfm
Be respectful! Clean up your posts before replying
____________________________________________________
_____
Do you Yahoo!?
Yahoo! Mail <http://rd.yahoo.com/mail/mailsig/*http://mailplus.yahoo.com>
Plus - Powerful. Affordable. Sign up
<http://rd.yahoo.com/mail/mailsig/*http://mailplus.yahoo.com> now
____________________________________________________ To change your JDJList
options, please visit: http://www.sys-con.com/java/list.cfm Be respectful!
Clean up your posts before replying
____________________________________________________
____________________________________________________
To change your JDJList options, please visit:
http://www.sys-con.com/java/list.cfm
Be respectful! Clean up your posts before replying
____________________________________________________
_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail
____________________________________________________
To change your JDJList options, please visit:
http://www.sys-con.com/java/list.cfm
Be respectful! Clean up your posts before replying
____________________________________________________
