JDK using gettimeofday and not clock_gettime?

Rohit Mohta rmohta.coder at gmail.com
Fri Jul 23 12:16:47 UTC 2021


  While developing an in-house tool on system time related manipulation, we
learnt Java uses gettimeofday() on linux-x86_64 system call for fetching

I was wondering if we thought of using clock_gettime() system call on
Linux? Or if there are plans to update them to align with the POSIX
recommendation. From what I can see Golang, Rust are using clock_gettime().

int status = gettimeofday(&time, NULL);

Per https://man7.org/linux/man-pages/man2/settimeofday.2.html

POSIX.1-2008 marks *gettimeofday*() as obsolete,
> recommending the use of clock_gettime(2)
> <https://man7.org/linux/man-pages/man2/clock_gettime.2.html> instead


More information about the jdk-dev mailing list