(no commit message)
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui.tests / stubs / org / eclipse / linuxtools / lttng / stubs / LTTngTimestampStub.java
1 /**
2 *
3 */
4 package org.eclipse.linuxtools.lttng.stubs;
5
6 import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
7
8 /**
9 * @author francois
10 *
11 */
12 public class LTTngTimestampStub extends TmfTimestamp {
13
14 /**
15 *
16 */
17 private static final long serialVersionUID = 216576768443708259L;
18
19 /**
20 * @param value
21 * @param scale
22 * @param precision
23 */
24 public LTTngTimestampStub(long value) {
25 super(value, (byte) -3, 0); // millisecs
26 }
27
28 /* (non-Javadoc)
29 * @see org.eclipse.linuxtools.tmf.event.TmfTimestamp#toString()
30 */
31 @Override
32 public String toString() {
33
34 // If we are dealing with units of seconds (or higher),
35 // use the plain formatter
36 if (fScale >= 0) {
37 Double value = fValue * Math.pow(10, fScale);
38 return value.toString();
39 }
40
41 // Define a format string
42 String format = String.format("%%1d.%%0%dd", -fScale);
43
44 // And format the timestamp value
45 double scale = Math.pow(10, fScale);
46 long seconds = (long) (fValue * scale);
47 long fracts = fValue - (long) ((double) seconds / scale);
48 String result = String.format(format, seconds, fracts);
49
50 return result;
51 }
52 }
This page took 0.030308 seconds and 5 git commands to generate.