# Java

시간을 기반으로 한 유니크한 문자열 만드는 방법
https://stackoverflow.com/questions/9191288/creating-a-unique-timestamp-in-java

    private static final AtomicLong LAST_TIME_MS = new AtomicLong();
    private static long uniqueCurrentTimeMS() {
        long now = System.currentTimeMillis();
        while (true) {
            long lastTime = LAST_TIME_MS.get();
            if (lastTime >= now)
                now = lastTime + 1;
            if (LAST_TIME_MS.compareAndSet(lastTime, now))
                return now;
        }
    }

 

소요시간 구하기

https://www.baeldung.com/java-measure-elapsed-time

long start = System.currentTimeMillis();

// ... code

long finish = System.currentTimeMillis();
long timeElapsed = finish - start;

 

# MySql

시간 차이 구하는 SQL

https://stackoverflow.com/questions/10907750/calculate-difference-between-two-datetimes-in-mysql

SELECT TIMESTAMPDIFF(SECOND, '2020-06-02 14:11:20', '2020-06-01 16:10:25')

 

 

+ Recent posts