How to get the current UTC time in seconds
问题 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? 回答1: You can use this to get timezone passing in timezone you want time back in Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); Then you can call whatever you want on the calendar object System.out.println(cal.get(Calendar.YEAR)); System.out.println(cal.get(Calendar.HOUR)); System.out