Java Time Format formatTime(int seconds)

Here you can find the source of formatTime(int seconds)

Description

format Time

License

Open Source License

Declaration

public static String formatTime(int seconds) 

Method Source Code

//package com.java2s;
/*//from  ww  w.j a v  a  2s . c  om
 * Copyright Siemens AG, 2014-2016.
 * With modifications by Bosch Software Innovations GmbH, 2016
 * Part of the SW360 Portal Project.
 *
 * SPDX-License-Identifier: EPL-1.0
 *
 * 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
 */

public class Main {
    public static String formatTime(int seconds) {
        if (seconds < 0) {
            return "not set";
        }
        int hours = seconds / 3600;
        int remainder = seconds % 3600;
        int minutes = remainder / 60;
        seconds = remainder % 60;
        return String.format("%02d:%02d:%02d", hours, minutes, seconds);
    }
}

Related

  1. formatTime(final long timeMS)
  2. formatTime(float seconds)
  3. formatTime(int minutes)
  4. formatTime(int minutes)
  5. formatTime(int originalTime)
  6. formatTime(int seconds)
  7. formatTime(int seconds)
  8. formatTime(int secs)
  9. formatTime(int time)