tmf/lttng: Update 2014 copyrights
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / 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.linuxtools.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.linuxtools.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 * @since 3.0
26 */
27 public class TmfChartTimeStampFormat extends SimpleDateFormat {
28
29 // ------------------------------------------------------------------------
30 // Constants
31 // ------------------------------------------------------------------------
32 private static final long serialVersionUID = 3719743469686142387L;
33
34 // ------------------------------------------------------------------------
35 // Attributes
36 // ------------------------------------------------------------------------
37 private long fOffset;
38
39 // ------------------------------------------------------------------------
40 // Constructors
41 // ------------------------------------------------------------------------
42 /**
43 * Standard Constructor
44 *
45 * @param offset
46 * offset to apply before formatting time (time = time + offset)
47 */
48 public TmfChartTimeStampFormat(long offset) {
49 fOffset = offset;
50 }
51
52 // ------------------------------------------------------------------------
53 // Operations
54 // ------------------------------------------------------------------------
55 @Override
56 public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
57
58 long time = date.getTime() + fOffset;
59 toAppendTo.append(TmfTimestampFormat.getDefaulTimeFormat().format(time));
60 return toAppendTo;
61 }
62
63 }
This page took 0.033391 seconds and 5 git commands to generate.