How-to articles, tricks, and solutions about GMT

How can I get the current date and time in UTC or GMT in Java?

To get the current date and time in UTC or GMT in Java, you can use the Instant class from the java.time package. The Instant class represents a single point in time in the ISO-8601 calendar system, with a resolution of nanoseconds.