I need to know using Java if the user that executes the Java class has the required permission to change the system time.
I just need a boolean returning method.
I need to know using Java if the user that executes the Java class has the required permission to change the system time.
I just need a boolean returning method.
That's not trivial.
On Unix-based systems, you can check whether the current user has the capability CAP_SYS_TIME
but there is no standard way to check this from Java.
On Windows, they will need admin rights but I don't know which permission exactly. Like on Unix, there is no Java API that you could use to check.
Maybe an external script/binary could do the check. You could then use ProcessBuilder
to execute this tool.