I have an application, which needs to compare the time in seconds.
I want to know how to get the current UTC time in seconds.
Can some one post an example of it how can we do this in Java?
I have an application, which needs to compare the time in seconds.
I want to know how to get the current UTC time in seconds.
Can some one post an example of it how can we do this in Java?
Get current UTC time in seconds (since 1.5) :
according to Javadoc:
This works:
You can use this to get timezone passing in timezone you want time back in
Then you can call whatever you want on the calendar object
Below example to compare two calendars in seconds
System.currentTimeMillis()
To store the date as an integer instead of long, you can divide by 1000 and optionally subtract by another date, such as Jan. 1 2019: