SimpleDateFormat 2005-09-21 - By Richard Yee
Back Frans, The DateFormat class is not threadsafe and making only one instance of dateFormat for the whole class will cause threading issues. Any instance of DateFormat or SimpleDateFormat should be method-local
-Richard
Frans Verhoef wrote: > Hi, > Make dateFormat a final static variable. This would create only one instance of dateFormat for the whole class. > > Cheers, > Frans > > On Tue, 20 Sep 2005 17:36:26 -0600, SUBSCRIBE EJB-INTEREST anonymous wrote: > >> Hi, >> Is there a better way to do the below in a multithreaded >> application? >> >> java.text.SimpleDateFormat dateFormat = new >> java.text.SimpleDateFormat ("MMddyyyy"); String formatedString = >> dateFormat.format(new Date()); >> >> I have the below code within a method in a class. >> >> Since, an instance of java.text.SimpleDateFormat will be created >> for every call of the method, I was wondering this would create lot >> of objects in heap. >> >> >> Thanks in advance, >> >> ====================================================================== >> ===== To unsubscribe, send email to listserv@(protected) and >> include in the body of the message "signoff J2EE-INTEREST". For >> general help, send email to listserv@(protected) and include in >> the body of the message "help". >> > > =========================================================================== > To unsubscribe, send email to listserv@(protected) and include in the body > of the message "signoff J2EE-INTEREST". For general help, send email to > listserv@(protected) and include in the body of the message "help". > > > >
=========================================================================== To unsubscribe, send email to listserv@(protected) and include in the body of the message "signoff J2EE-INTEREST". For general help, send email to listserv@(protected) and include in the body of the message "help".
|
|