Answers for "how to convert hours and minutes to seconds in java"

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
0

java long to hours minutes and seconds

Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date(millis));

//And then....
calendar.get(Calendar.HOUR_OF_DAY) //use Calendar.HOUR for AM format
calendar.get(Calendar.MINUTE)
calendar.get(Calendar.SECOND)
Posted by: Guest on April-24-2021

Code answers related to "how to convert hours and minutes to seconds in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language