You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Scott Morgan <mo...@gmail.com> on 2005/06/01 17:11:09 UTC

Re: Date Formatter - not thread safe

jakarta commons FastDateFormat is thread-safe

http://jakarta.apache.org/commons/lang/api/org/apache/commons/lang/time/FastDateFormat.html

On 5/29/05, Erik Hatcher <er...@ehatchersolutions.com> wrote:
> 
> On May 29, 2005, at 2:04 PM, Jamie Orchard-Hays wrote:
> 
> > Yeah, I'd forgotten that. I'm sure it's why we put these in our
> > Visit class.
> 
> The idea (in the Darden design) to use a hard-coded data format, but
> in a Visit-centric way so that in the future if you wanted to provide
> Locale-specific handling it could be done on a per-Visit basis.
> 
>      Erik
> 
> 
> >
> > Jamie
> >
> >
> > On May 27, 2005, at 5:03 PM, btomasini@neteverything.com wrote:
> >
> >
> >> SimpleDateFormat is not thread safe.  You will get weird behavior
> >> under
> >> high concurrency.
> >>
> >> It cannot be static in the Global, you do have the following options:
> >>
> >> 1) make the pattern static in Global, and do a new
> >> SimpleDateFormat for
> >> each get.
> >>
> >> 2) make the SimpleDateFormat static in Visit, since you can be
> >> assured for
> >> the most part that it will not be accessed by multiple threads at
> >> once.
> >>
> >> Ben
> >>
> >>
> >>> Thanks - worked like a charm.
> >>>
> >>> Patrick
> >>>
> >>> Jamie Orchard-Hays wrote:
> >>>
> >>>
> >>>> You could put your format strings in your Visit or Global object:
> >>>>
> >>>>
> >>>> private static final SimpleDateFormat SHORT_DATETIME_FORMAT = new
> >>>> SimpleDateFormat("MM/dd/yy h:mm a");
> >>>> private static final SimpleDateFormat DEADLINE_DATETIME_FORMAT =
> >>>> new
> >>>> SimpleDateFormat("EEEE, MMMM d, yyyy @ h:mm a");
> >>>>
> >>>> Then make getters so your ognl reference isn't hideously long:
> >>>> public Format getShortDatetimeFormat(){
> >>>>    return SHORT_DATETIME_FORMAT;
> >>>> }
> >>>> public Format getDeadlineDatetimeFormat() {
> >>>>     return DEADLINE_DATETIME_FORMAT;
> >>>> }
> >>>>
> >>>> and then use them in your ognl expression:
> >>>>
> >>>> <component id="jobResumeDeadline" type="common:Write">
> >>>>     <binding name="value" expression="job.resumeDueDate"/>
> >>>>     <binding name="format"
> >>>> expression="visit.deadlineDatetimeFormat"/>
> >>>> </component>
> >>>>
> >>>> (common:Write) is our own customized version of Insert)
> >>>>
> >>>> Patrick Kelly wrote:
> >>>>
> >>>>
> >>>>> I have a date originally set as "new
> >>>>> java.sql.Timestamp(time.getTime()" to my DB.  I retrieve the
> >>>>> data in
> >>>>> string format such as "2005-05-13 12:10:57.0" and I am able to
> >>>>> bind
> >>>>> it with no problem.  However, I need to format the date such as
> >>>>> "MMM
> >>>>> dd, yy, HH:mm:ss" in the binding of a table model.  I would
> >>>>> rather do
> >>>>> the formatting within the .page file than in a .java file.
> >>>>>
> >>>>> Any help would be appreciated,
> >>>>> Thanks - Patrick
> >>>>>
> >>>>>
> >>>>> ------------------------------------------------------------------
> >>>>> ---
> >>>>> To unsubscribe, e-mail: tapestry-user-
> >>>>> unsubscribe@jakarta.apache.org
> >>>>> For additional commands, e-mail: tapestry-user-
> >>>>> help@jakarta.apache.org
> >>>>>
> >>>>>
> >>>>>
> >>>>
> >>>> -------------------------------------------------------------------
> >>>> --
> >>>> To unsubscribe, e-mail: tapestry-user-
> >>>> unsubscribe@jakarta.apache.org
> >>>> For additional commands, e-mail: tapestry-user-
> >>>> help@jakarta.apache.org
> >>>>
> >>>>
> >>>
> >>> --
> >>> Patrick Kelly
> >>> E-Learning Consultant
> >>> Learning Commons, University of Calgary
> >>> http://commons.ucalgary.ca
> >>> Phone: 220-2547
> >>>
> >>>
> >>> --------------------------------------------------------------------
> >>> -
> >>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> >>> For additional commands, e-mail: tapestry-user-
> >>> help@jakarta.apache.org
> >>>
> >>>
> >>>
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> >> For additional commands, e-mail: tapestry-user-
> >> help@jakarta.apache.org
> >>
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
>

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