Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 276d99de52664e1ba40cb5d6d0b65c0e19c64aa9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package org.eclipse.linuxtools.tmf.core.ctfadaptor;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;

public class CtfTmfTimestamp extends TmfTimestamp implements ITmfTimestamp {

    final private CtfTmfTrace fTrace;

    public CtfTmfTimestamp(long timestamp, CtfTmfTrace trace) {
        fTrace = trace;
        fValue = timestamp;
        fScale = (byte) -9;
    }

    /*
     * (non-Javadoc)
     *
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        final long timestamp = fValue;
        final Date d = new Date(timestamp / 1000000);
        final DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss."); //$NON-NLS-1$
        final long nanos = (timestamp % 1000000000);
        StringBuilder output = new StringBuilder();
        output.append(df.format(d));
        output.append(String.format("%09d", nanos)); //$NON-NLS-1$
        return output.toString();
    }

}

Back to the top