[Opensource] SimpleDateFormat

Vincent Gogan vincent.gogan at goganinc.com
Wed Mar 12 08:53:47 PST 2003


Creating a wrapper makes sense from a design point of view but it hides a
possible performance issue hinted at in Ben's code.

SimpleDateFormat is not thread safe and if date formatting becomes a global
resource then you are synchronizing a fairly expensive operation across the
entire application. There are many reasons why you may want to format a date
(logging, setting headers, etc.) on a per page basis and synchronizing on every
page request is not a good thing.

Hmmm, we have a FastStringBuffer, why not a FastDateFormat?

Vincent

-----Original Message-----
From: opensource-admin at jcorporate.com
[mailto:opensource-admin at jcorporate.com]On Behalf Of Michael Rimov
Sent: Tuesday, March 11, 2003 6:20 PM
To: opensource at jcorporate.com
Subject: Re: [Opensource] SimpleDateFormat


At 02:37 PM 3/11/2003 -0500, you wrote:
>Good day all.
>
>I've been contemplating how best to format dates on an application wide
>basis.  What I've done is as follows:

Ben,

Instead, why don't you create a wrapper object that wraps a DBObject to get
what you want.  By implementing a quick 'factory' method, you could end up
with code like so:

WrapperObject wrap = WrapperObject.wrap(DBObject obj);
String formattedDate = wrap.getDateField(String fieldName);

Something along these lines would give you two advantages:

1 - Proper division of labor.  The wrapper does what it's supposed to...
which is provide date formatting.

2 - We avoid yet more methods in DBObject, which I'm trying to split up anyway.

3 - No patching the code while you wait for it to show up in CVS :)

Does this help?
                                                         -Mike


_______________________________________________
Opensource mailing list
Opensource at jcorporate.com
http://mail.jcorporate.com/mailman/listinfo/opensource
Archives: http://mail.jcorporate.com/pipermail/opensource/




More information about the Opensource mailing list