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 timeFormatMillis(int millis) {
        long seconds = TimeUnit.MILLISECONDS.toSeconds(millis);
        long minutes = seconds / 60;
        seconds = seconds - minutes * 60;
        return String.format("%01d:%02d", minutes, seconds);
    }

    public static String timeFormatMillis(String millis) {
        try {
            int value = Integer.valueOf(millis);
            return timeFormatMillis(value);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}