analysis: Move plugins to their own sub-directory
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.ui / src / org / eclipse / tracecompass / tmf / ui / viewers / xycharts / TmfChartTimeStampFormat.java
1 /**********************************************************************
2 * Copyright (c) 2013, 2014 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12 package org.eclipse.tracecompass.tmf.ui.viewers.xycharts;
13
14 import java.text.FieldPosition;
15 import java.text.SimpleDateFormat;
16 import java.util.Date;
17
18 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestampFormat;
19
20 /**
21 * SimpleDateFormat class for displaying time information in SWT charts
22 * using the TmfTimestampFormat class.
23 *
24 * @author Bernd Hufmann
25 */
26 public class TmfChartTimeStampFormat extends SimpleDateFormat {
27
28 // ------------------------------------------------------------------------
29 // Constants
30 // ------------------------------------------------------------------------
31 private static final long serialVersionUID = 3719743469686142387L;
32
33 // ------------------------------------------------------------------------
34 // Attributes
35 // ------------------------------------------------------------------------
36 private long fOffset;
37
38 // ------------------------------------------------------------------------
39 // Constructors
40 // ------------------------------------------------------------------------
41 /**
42 * Standard Constructor
43 *
44 * @param offset
45 * offset to apply before formatting time (time = time + offset)
46 */
47 public TmfChartTimeStampFormat(long offset) {
48 fOffset = offset;
49 }
50
51 // ------------------------------------------------------------------------
52 // Operations
53 // ------------------------------------------------------------------------
54 @Override
55 public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
56
57 long time = date.getTime() + fOffset;
58 toAppendTo.append(TmfTimestampFormat.getDefaulTimeFormat().format(time));
59 return toAppendTo;
60 }
61
62 }
This page took 0.033251 seconds and 6 git commands to generate.