Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.concurrent.TimeUnit;

public class Main {
    public static String getTimeSpanFromSeconds(long secs) {
        if (TimeUnit.SECONDS.toHours(secs) == 0)
            return String.format("%dmin", TimeUnit.SECONDS.toMinutes(secs));
        else
            return String.format("%dh %02dmin", TimeUnit.SECONDS.toHours(secs),
                    TimeUnit.SECONDS.toMinutes(secs) - TimeUnit.HOURS.toMinutes(TimeUnit.SECONDS.toHours(secs)));
    }
}