import java.time.*;
public class JavaTimeTest {
private static final long TICKS_AT_EPOCH = 621355968000000000L;
public static void main(String[] args) {
ZonedDateTime now = ZonedDateTime.now(ZoneId.of("UTC"));
long timestampWithNanos = now.toEpochSecond() * 10000000L;
timestampWithNanos += now.getNano() / 100;
timestampWithNanos += TICKS_AT_EPOCH;
System.out.println(timestampWithNanos);
long tick = System.currentTimeMillis() * 10000L + TICKS_AT_EPOCH;
System.out.println(tick);
Instant utcInstant = Clock.systemUTC().instant();
long ticks = utcInstant.getEpochSecond() * 10000000L;
ticks += utcInstant.getNano() / 100L;
ticks += TICKS_AT_EPOCH;
System.out.println(ticks);
}
}
실행 결과>
'java' 카테고리의 다른 글
java jsckson2 라이브러리 사용 null and default value ignore (2) | 2024.10.08 |
---|---|
spring boot 가상 스레드로 웹소켓 사용 (0) | 2024.07.20 |
java drawing random (1) | 2024.07.05 |
java windows 백그라운드 실행 및 종료 (0) | 2024.07.04 |
java Map ConcurrentModificationException 회피 (0) | 2024.07.04 |