2323 *******************************************************************************/
2424package org .eclipse .tracecompass .traceeventlogger ;
2525
26- import java .text .DecimalFormat ;
27- import java .text .Format ;
2826import java .util .Arrays ;
2927import java .util .HashMap ;
3028import java .util .HashSet ;
@@ -142,7 +140,7 @@ public interface IFlowScopeLog {
142140 int getId ();
143141 }
144142
145- private static final Format FORMAT = new DecimalFormat ( "#.###" ) ; //$NON-NLS-1$
143+ private static final String FORMAT = "%d.%03d" ; //$NON-NLS-1$
146144
147145 /**
148146 * Offset between System.currentTimeMillis() and System.nanoTime() in nanoseconds.
@@ -153,7 +151,7 @@ public interface IFlowScopeLog {
153151 // Get current time in both bases
154152 long currentMillis = System .currentTimeMillis ();
155153 long nanoTime = System .nanoTime ();
156-
154+
157155 // Convert millis to nanos and calculate offset, handling potential overflow
158156 long millisToNanos = currentMillis * 1_000_000L ;
159157 TIME_OFFSET = millisToNanos - nanoTime ;
@@ -163,7 +161,7 @@ public interface IFlowScopeLog {
163161 * Gets the current time in nanoseconds since the Unix epoch.
164162 * This maintains nanosecond precision while being comparable to timestamps from
165163 * System.currentTimeMillis().
166- *
164+ *
167165 * @return Current time in nanoseconds since Unix epoch
168166 */
169167 private static long currentTimeNanos () {
@@ -920,7 +918,7 @@ public static void traceMarker(Logger logger, Level level, String name, long dur
920918 * USE ME FIRST
921919 */
922920 private static StringBuilder appendCommon (StringBuilder appendTo , char phase , long time , long threadId ) {
923- writeObject (appendTo , TIMESTAMP , FORMAT .format (( double ) time / 1000 )).append (',' ); // $NON-NLS-1$
921+ writeObject (appendTo , TIMESTAMP , String .format (FORMAT , time / 1000 , time % 1000 )).append (',' ); // $NON-NLS-1$
924922 writeObject (appendTo , PHASE , phase ).append (',' );
925923 writeObject (appendTo , TID , threadId ).append (',' );
926924 return writeObject (appendTo , PID , threadId ); // $NON-NLS-1$
0 commit comments