1 /*******************************************************************************
2 * Copyright (c) 2007, 2011 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.simulation.experiment;
14 import java.math.RoundingMode;
15 import java.text.NumberFormat;
16 import java.util.Locale;
18 import org.simantics.utils.format.TimeFormat;
21 * @author Tuukka Lehtonen
23 public class SimulationTimeUtil {
25 private static final NumberFormat secondFormatter;
26 private static final TimeFormat timeFormat;
29 secondFormatter = NumberFormat.getNumberInstance(Locale.US);
30 secondFormatter.setMinimumFractionDigits(2);
31 secondFormatter.setMaximumFractionDigits(3);
32 secondFormatter.setRoundingMode(RoundingMode.HALF_EVEN);
34 timeFormat = new TimeFormat(Double.MAX_VALUE, 3);
37 public static String formatSeconds(double time) {
38 return secondFormatter.format(time);
42 * Formats a time specified as a double value in seconds in format
43 * <code>[Y]y [D]d hh:mm:ss.SSS</code>
48 public static String formatHMSS(double time) {
49 String result = timeFormat.format(time);
50 // System.out.println("formatHMSS(" + time + "): " + result);