Answers for "java convert seconds to days hours minutes"

5

seconds to hours java

int s=123456;
			int sec = s % 60;
		    int min = (s / 60)%60;
		    int hours = (s/60)/60;
            
		    String strSec=(sec<10)?"0"+Integer.toString(sec):Integer.toString(sec);
		    String strmin=(min<10)?"0"+Integer.toString(min):Integer.toString(min);
		    String strHours=(hours<10)?"0"+Integer.toString(hours):Integer.toString(hours);
		    
		    System.out.println(strHours + ":" + strmin + ":" + strSec);
Posted by: Guest on November-03-2020
-1

java 8 seconds to days

int day = (int)TimeUnit.SECONDS.toDays(seconds);        
 long hours = TimeUnit.SECONDS.toHours(seconds) - (day *24);
 long minute = TimeUnit.SECONDS.toMinutes(seconds) - (TimeUnit.SECONDS.toHours(seconds)* 60);
 long second = TimeUnit.SECONDS.toSeconds(seconds) - (TimeUnit.SECONDS.toMinutes(seconds) *60);
Posted by: Guest on April-03-2020

Code answers related to "java convert seconds to days hours minutes"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language