Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

In Java, the method to obtain the current date and time in UTC or GMT is as follows:

Instant.now().toString()

This method returns a string representing the current date and time in UTC/GMT timezone in the ISO-8601 date and time format. The Instant class is used to represent a point in time on the time-line in UTC.