Welcome to collectivesolver - Programming & Software Q&A with Examples. A website you can trust. All programs tested and work.

Contact: aviboots(AT)netvision.net.il


Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Survey Junkie is the #1 place online for your audience to earn rewards for their opinion.

100%
Managed VPS Hosting
Affordable. Secure. Your Own Virtual Private Hosting. Faster than AWS and Rackspace

Bonsai Boy of New York Bonsai Trees and Accessories
Liquid Web - Highest Level of Performance and Security with Managed Dedicated Servers

Disclosure We are a professional Programming & Software Q&A website, that receives compensation from some of the links whose we show you with Information. It means that my content may contain affiliate links.

21,340 questions

28,142 answers

573 users

How to convert milliseconds to minutes and seconds in Java

1 Answer

0 votes
import java.util.concurrent.TimeUnit;

public class MyClass {
    public static void main(String args[]) {
        long milliseconds = 1000000;

        long seconds = TimeUnit.MILLISECONDS.toSeconds(milliseconds);
        System.out.println(milliseconds + " Milliseconds = " + seconds + " Seconds");
        System.out.println(milliseconds * 0.001);

        long minutes = TimeUnit.MILLISECONDS.toMinutes(milliseconds);
        System.out.println(milliseconds + " Milliseconds = " + minutes + " Minutes");
        System.out.println((milliseconds * 0.001) / 60);
        System.out.println(milliseconds * 0.001 * 0.0166667);
    }
}
   
  
  
   
/*
run:
  
1000000 Milliseconds = 1000 Seconds
1000.0
1000000 Milliseconds = 16 Minutes
16.666666666666668
16.6667

*/

 




answered 6 days ago by avibootz
...