Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    static String formatTimeNice(float seconds) {
        int hh = (int) Math.floor(seconds / 3600);
        seconds = seconds - hh * 3600;
        int mm = (int) Math.floor(seconds / 60);
        seconds = seconds - mm * 60;
        int ss = (int) Math.floor(seconds);

        if (hh > 0)
            return String.format("%dh %02dm %02ds", hh, mm, ss);
        else
            return String.format("%dm %02ds", mm, ss);
    }
}