I have a piece of code that finds the difference between two dates (in the format yyyy-MM-dd hh: mm: ss). This code runs on several servers around the world. One of the two dates is the current time in the specific time zone in which the code is executed (server time), and the other is the time received from the database. if the difference between the two times exceeds 86400 seconds (1 day), then it should print “invalid”, otherwise “valid” should be printed. The problem that the code encounters is that I run it on my local computer, it is operational, but when I deploy it on a server in the USA, it takes into account GMT time, not local time. Wherever the code runs, I want the difference between the current time and the time received from the database, and if it exceeds 86400 seconds,I want to print invalid. How to achieve this in java? PS: I tried the Date object, but considered GMT only everywhere.
source
share