Core Java
[Core Java] 경과 시간 구하기
헤르메스의날개
2020. 12. 29. 14:16
728x90
public class DateSample {
static Logger logger = LoggerFactory.getLogger( DateSample.class );
public static void main( String[] args ) {
try {
long start = System.currentTimeMillis(); //시작하는 시점 계산
Thread.sleep( 10000 );
long end = System.currentTimeMillis(); //프로그램이 끝나는 시점 계산
logger.info( "실행 시간 : " + ( end - start ) / 1000.0 + "초" ); //실행 시간 계산 및 출력
} catch ( InterruptedException ie ) {
logger.info( "[InterruptedException] {}", ie.getMessage() );
}
}
결과
INFO : sample.StringSample - 실행 시간 : 10.001초 |
728x90