System.currentTimeMillis()
현재시간을 Mill sec으로 표현해주는 것.
ex) jshell> System.currentTimeMillis();
==> 1677724410793 // year, month, date, h:m:s 밀리단위의 시간까지 알아봄
jshell> System.currentTimeMillis() / 1000; // 현재의 초단위까지 알아보기
==> 1677724556
jshell> System.currentTimeMillis() / 1000%60 // 현재의 초를 구하는 식
jshell> System.currentTimeMillis() / 1000/60 // epoch 분
System.currentTimeMillis() / 1000/60%60 // 현재의 분을 구하는 식
jshell> System.currentTimeMillis() / 1000/60/60 // epoch 시간
jshell> System.currentTimeMillis() / 1000/60/60%24 // 현재 세계표준 시간이 나옴 (GMT) // 영국런던기준.
// 한국표준시 (GMT +9)
jshell> System.currentTimeMillis() / 1000/60/60%24 + 9 // 한국 현재 시간 Korea Standard Time
jshell> long epoch = System.currentTimeMillis() /1000;
jshell> int second = (int)(epoch%60);
jshell> int minute = (int)(epoch/60%60);
jshell> int hour = (int)(epoch/60/60%24) + 9
jshell> System.out.printf("%d:%d:%d", hour, minute, second);
jshell> System.out.printf("%02d:%02d:%02d", hour, minute, second);
What is meant by epoch time?
= In a computing context,
an epoch is the date and time relative to which a computer's clock and timestamp values are determined.
The epoch traditionally corresponds to 0 hours, 0 minutes, and
0 seconds (00:00:00) Coordinated Universal Time (UTC) on a specific date, which varies from system to system.
Unix time = Epoch time
유닉스 시간은 시각을 나타내는 방식이다.
POSIX 시간이나 Epoch 시간이라고 부르기도 한다.
1970년 1월 1일 00:00:00 협정 세계시 부터의 경과 시간을 초로 환산하여 정수로 나타낸 것이다.
유닉스 시간에서 윤초는 무시된다.
jshell 에서 히스토리를 보고 싶으면 : /list 를 입력하면 히스토리가 출력한다.
Hello World
jshell - System.currentTimeMillis() / epoch time / (GMT) - jshell을 이용해서 한국 현재 시간 구하기 [개발스터디 기몬]
728x90
반응형
728x90
반응형
댓글