반응형
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;
}
반응형
'Java' 카테고리의 다른 글
[Java] 배열에 특정 값 존재(포함)여부 체크 (0) | 2022.03.19 |
---|---|
[Java] 정규식(Regular Expression) (0) | 2022.03.19 |
[Java] 초단위 -> 문자열 시분초로 변환(secToTime) 구현 (0) | 2021.10.15 |
[Java] 이모티콘(Emoji) 처리(EmojiManager, EmojiParser 클래스 사용) (0) | 2021.10.15 |
[Java] 특수문자, Entity Code 치환(StringEscapeUtils 클래스 사용) (0) | 2021.09.11 |