[Java] 문자열 시분초 -> 초단위로 변환(timeToSec) 구현

[Java] 문자열 시분초 -> 초단위로 변환(timeToSec) 구현

public static int timeToSec( String time) {

String [] times = time. split ( ":" );

int hours = Integer. parseInt (times[ 0 ]);

int minutes = Integer. parseInt (times[ 1 ]);

int seconds = Integer. parseInt (times[ 2 ]);

int totalSeconds = ( + hours) * 60 * 60 + ( + minutes) * 60 + ( + seconds);

return totalSeconds;

}

from http://jinalim-dev.tistory.com/37 by ccl(A) rewrite - 2021-10-15 19:27:42