Languages
[Edit]
EN

Java - timestamp milliseconds to microseconds

7 points
Created by:
LionRanger
371

Quick solution:

import java.sql.Timestamp;
import java.time.Instant;
import java.time.temporal.ChronoUnit;

public class Example {

    public static void main(String[] args) {
        Timestamp timestamp = new Timestamp(1631189155668L);

        System.out.println("1) " + timestamp.getTime());
        System.out.println("2) " + timestamp.getTime() * 1000);
        System.out.println("3) " + ChronoUnit.MICROS.between(Instant.EPOCH, timestamp.toInstant()));

        // 1) 1631189155668
        // 2) 1631189155668000
        // 3) 1631189155668000
    }
}

 

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join