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