Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.util.Locale;

import java.util.concurrent.TimeUnit;

public class Main {
    /**
     * millisecondsToHours
     * Get the hh:mm value from milliseconds
     * @param millis the milliseconds value
     * @return a string with the time in hh:mm format
     */
    public static String millisecondsToHours(long millis) {
        return String.format(Locale.getDefault(), "%02d:%02d", TimeUnit.MILLISECONDS.toHours(millis),
                TimeUnit.MILLISECONDS.toMinutes(millis) % TimeUnit.HOURS.toMinutes(1));
    }
}