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