tmf: Remove unneeded annotations in the CTF adaptor
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / ctfadaptor / CtfTmfTimestamp.java
1 package org.eclipse.linuxtools.tmf.core.ctfadaptor;
2
3 import java.text.DateFormat;
4 import java.text.SimpleDateFormat;
5 import java.util.Date;
6
7 import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
8
9 public class CtfTmfTimestamp extends TmfTimestamp {
10
11 final private CtfTmfTrace fTrace;
12
13 public CtfTmfTimestamp(long timestamp, CtfTmfTrace trace) {
14 fTrace = trace;
15 setValue(timestamp, -9, 0);
16 }
17
18 /* (non-Javadoc)
19 * @see java.lang.Object#hashCode()
20 */
21 @Override
22 public int hashCode() {
23 final int prime = 31;
24 int result = super.hashCode();
25 result = (prime * result) + ((fTrace == null) ? 0 : fTrace.hashCode());
26 return result;
27 }
28
29 /* (non-Javadoc)
30 * @see java.lang.Object#equals(java.lang.Object)
31 */
32 @Override
33 public boolean equals(Object obj) {
34 if (this == obj) {
35 return true;
36 }
37 if (!super.equals(obj)) {
38 return false;
39 }
40 if (!(obj instanceof CtfTmfTimestamp)) {
41 return false;
42 }
43 CtfTmfTimestamp other = (CtfTmfTimestamp) obj;
44 if (fTrace == null) {
45 if (other.fTrace != null) {
46 return false;
47 }
48 } else if (!fTrace.equals(other.fTrace)) {
49 return false;
50 }
51 return true;
52 }
53
54 /*
55 * (non-Javadoc)
56 *
57 * @see java.lang.Object#toString()
58 */
59 @Override
60 public String toString() {
61 final long timestamp = getValue();
62 final Date d = new Date(timestamp / 1000000);
63 final DateFormat df = new SimpleDateFormat("HH:mm:ss."); //$NON-NLS-1$
64 final long nanos = (timestamp % 1000000000);
65 StringBuilder output = new StringBuilder();
66 output.append(df.format(d));
67 output.append(String.format("%09d", nanos)); //$NON-NLS-1$
68 return output.toString();
69 }
70
71 public String toFullDateString(){
72 final long timestamp = getValue();
73 final Date d = new Date(timestamp / 1000000);
74 final DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss."); //$NON-NLS-1$
75 final long nanos = (timestamp % 1000000000);
76 StringBuilder output = new StringBuilder();
77 output.append(df.format(d));
78 output.append(String.format("%09d", nanos)); //$NON-NLS-1$
79 return output.toString();
80 }
81
82 }
This page took 0.032844 seconds and 6 git commands to generate.