I want to know the current Date and Time.
The code
Calendar.getInstance();
represents a date and time of the system on which the program is running and the system date can be wrong.
So Is there any way by which I can get correct current date and time irrespective of the date and time of the system on which program is running?
If you’re on the internet, you might be able to ask a known and trusted time source. If the person running your program wants to prevent your program from doing that (like if you’ve given them a time limited license and they don’t want to pay for more time), they might spoof or block that connection.
On one project I was on, we placed a secure, trusted time source in the hardware that could not be tampered with. It was designed for encryption and licensing, and had a Java library to access it. Sorry, I can’t remember the name of the device.
So the answer is maybe yes, maybe no.