Java Second Format getFormattedDuration(int simTimeSeconds)

Here you can find the source of getFormattedDuration(int simTimeSeconds)

Description

get Formatted Duration

License

Open Source License

Return

the simulation time in the following format hh:mm:ss

Declaration

public static String getFormattedDuration(int simTimeSeconds) 

Method Source Code


//package com.java2s;
/*//  ww  w .j a  v  a2s. c  o  m
 * #%L
 * Common
 * %%
 * Copyright (C) 2011 - 2015 Intuit Inc.
 * %%
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * #L%
 */

import java.text.NumberFormat;

public class Main {
    private static final int TIME_60 = 60;
    private static final int TIME_3600 = 3600;
    private static NumberFormat nf;

    /**
     * @return the simulation time in the following format hh:mm:ss
     */
    public static String getFormattedDuration(int simTimeSeconds) {
        int hours = simTimeSeconds / TIME_3600;
        simTimeSeconds = simTimeSeconds - (hours * TIME_3600);
        int minutes = simTimeSeconds / TIME_60;
        simTimeSeconds = simTimeSeconds - (minutes * TIME_60);
        int seconds = simTimeSeconds;
        return nf.format(hours) + ":" + nf.format(minutes) + ":" + nf.format(seconds);
    }
}

Related

  1. formatTimeSpanSeconds(long span)
  2. formatTimeWithOutSeconds(java.util.Date d)
  3. getDHMS(long totalSecond)
  4. getElapsedSeconds(long startTime)
  5. getFormatMSecond(long long_)
  6. getFullDateByMisSecond(long misSecond)
  7. getFutureDate(int seconds)
  8. getIntervalMilSeconds(String startDateStr, String endDateStr, String dateFormat)
  9. getMisSecond(String strDate)