1 /*******************************************************************************
2 * Copyright (c) 2015, 2016 EfficiOS Inc. and others
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 *******************************************************************************/
10 package org
.eclipse
.tracecompass
.internal
.provisional
.analysis
.lami
.core
.module
;
12 import java
.text
.FieldPosition
;
13 import java
.text
.SimpleDateFormat
;
14 import java
.util
.Date
;
16 import org
.eclipse
.jdt
.annotation
.Nullable
;
17 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.TmfTimestampFormat
;
20 * Formatter for time stamps
22 public class LamiTimeStampFormat
extends SimpleDateFormat
{
24 private static final long serialVersionUID
= 4285447886537779762L;
26 private final TmfTimestampFormat fFormat
;
28 // ------------------------------------------------------------------------
30 // ------------------------------------------------------------------------
33 * The default constructor (uses the default time format)
35 public LamiTimeStampFormat() {
36 fFormat
= TmfTimestampFormat
.getDefaulTimeFormat();
40 * The normal constructor
42 * @param pattern the format pattern
44 public LamiTimeStampFormat(String pattern
) {
45 fFormat
= new TmfTimestampFormat(pattern
);
48 // ------------------------------------------------------------------------
50 // ------------------------------------------------------------------------
53 public StringBuffer
format(@Nullable Date date
, @Nullable StringBuffer toAppendTo
,
54 @Nullable FieldPosition fieldPosition
) {
55 if (date
!= null && toAppendTo
!= null) {
56 long time
= date
.getTime();
57 toAppendTo
.append(fFormat
.format(time
));
60 return new StringBuffer();