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
CommitLineData
83842d7d 1/**********************************************************************
60ae41e1 2 * Copyright (c) 2013, 2014 Ericsson
83842d7d
BH
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 **********************************************************************/
2bdf0193 12package org.eclipse.tracecompass.tmf.ui.viewers.xycharts;
83842d7d
BH
13
14import java.text.FieldPosition;
15import java.text.SimpleDateFormat;
16import java.util.Date;
17
2bdf0193 18import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestampFormat;
83842d7d
BH
19
20/**
21 * SimpleDateFormat class for displaying time information in SWT charts
22 * using the TmfTimestampFormat class.
23 *
24 * @author Bernd Hufmann
83842d7d
BH
25 */
26public 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.062514 seconds and 5 git commands to generate.