Author: erodriguez Date: Tue Jan 18 02:49:28 2005 New Revision: 125476 URL: http://svn.apache.org/viewcvs?view=rev&rev=125476 Log: Enhancement, date formatting using static initializer. Modified: incubator/directory/ntp/trunk/core/src/java/org/apache/ntp/message/NtpTimeStamp.java
Modified: incubator/directory/ntp/trunk/core/src/java/org/apache/ntp/message/NtpTimeStamp.java Url: http://svn.apache.org/viewcvs/incubator/directory/ntp/trunk/core/src/java/org/apache/ntp/message/NtpTimeStamp.java?view=diff&rev=125476&p1=incubator/directory/ntp/trunk/core/src/java/org/apache/ntp/message/NtpTimeStamp.java&r1=125475&p2=incubator/directory/ntp/trunk/core/src/java/org/apache/ntp/message/NtpTimeStamp.java&r2=125476 ============================================================================== --- incubator/directory/ntp/trunk/core/src/java/org/apache/ntp/message/NtpTimeStamp.java (original) +++ incubator/directory/ntp/trunk/core/src/java/org/apache/ntp/message/NtpTimeStamp.java Tue Jan 18 02:49:28 2005 @@ -37,6 +37,12 @@ private static final long NTP_EPOCH_DIFFERENCE = -2208988800000L; private static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone( "UTC" ); + private static final SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss.SSS z" ); + + static + { + dateFormat.setTimeZone( UTC_TIME_ZONE ); + } private long seconds = 0; private long fraction = 0; @@ -93,11 +99,7 @@ long msSinceStartOfNtpEpoch = seconds * 1000 + ( fraction * 1000 ) / 0x100000000L; Date date = new Date( msSinceStartOfNtpEpoch + NTP_EPOCH_DIFFERENCE ); - SimpleDateFormat format = new SimpleDateFormat(); - format.setTimeZone( UTC_TIME_ZONE ); - format.applyPattern( "yyyy-MM-dd HH:mm:ss.SSS z" ); - - return "org.apache.ntp.message.NtpTimeStamp[ date = " + format.format( date ) + " ]"; + return "org.apache.ntp.message.NtpTimeStamp[ date = " + dateFormat.format( date ) + " ]"; } public boolean equals( Object o )
