Ask Your Question
2

In Java, what is the method to obtain the current date and time in UTC or GMT?

asked 2023-06-03 14:35:50 +0000

david gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-06-03 15:00:02 +0000

lakamha gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-06-03 14:35:50 +0000

Seen: 14 times

Last updated: Jun 03 '23