Coders Packet

Conversion of milliseconds to seconds and minutes using Java

By Kajjayam Priya

The program is about converting milliseconds to seconds and minutes with the help of primitive data types. The programming language used in the source code is Java.

This source code is about conversion of millisecond to seconds and minutes. The metrices of milliseconds, seconds and minutes are 1000milliseconds=1second,60seconds= 1minute.With the basic formulas of the given parameters that is for seconds(milliseconds/1000)/60) and for minutes (milliseconds/1000)%60) conversion can be done. 

import java util.concurrent.TimeUnit;
class Main
public static void main(String[] args)
Long milliseconds = 1859555;
Long seconds = TimeUnit.MILLISECONDS.toseconds(milliseconds);
System.out.println(milliseconds + " Milliseconds = " + seconds + " Seconds");
Long minutes=TimeUnit.MILLISECONDS.toMinutes(milliseconds);
System.out.println(milliseconds + " Milliseconds = " + minutes + " Minutes");



Download Complete Code


No comments yet