Thanks Bian and Chad. I just committed this to CVS ;) On Thu, 13 Dec 2001 10:38, Bian Tan wrote: > Good Catch! Chad Stansbury! > > Pity, looks like Peter Donald already checked in the original > Perhaps we can get the more optimal code checked in too? > Is there an upcoming release of LogKit? > > > -----Original Message----- > From: Chad Stansbury [mailto:[EMAIL PROTECTED] > Sent: Wednesday, December 12, 2001 3:09 PM > > For the speed freaks like myself, here's another optimization to the Date > formatter code. You can improve upon the speed by removing the Date > instantiation (which in the quoted code will be invoked for each line being > logged), and replacing w/ a setTime call... The new code would be: > > import java.util.Date; > import java.text.SimpleDateFormat; > > SimpleDateFormat m_dateFormatter = null; > Date m_date = new Date(); > > protected String getTime( final long time, final String format ) > { > if ( format == null ){ > return Long.toString( time ); > } > > if (m_dateFormatter == null) { > m_dateFormatter = new SimpleDateFormat( format ); > } > > m_date.setTime( System.currentTimeMillis() ); > return( m_dateformatter.format( m_date ) ); > } > > Chad Stansbury
-- Cheers, Pete ------------------------------------------------------- To fight and conquer in all your battles is not supreme excellence; supreme excellence consists in breaking the enemy's resistance without fighting. - Sun Tzu, 300 B.C. ------------------------------------------------------- -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>