Here is an example of a Java program to get GMT:
Java - Get GMT Example
import java.util. *; import java.text. *; public class GetGMTTime { public static void main(String[] args) { SimpleDateFormat df = new SimpleDateFormat("yyyy MMM dd HH:mm:ss zzz"); Date date = new Date(); System.out.println("Local Time: " + df.format(date)); df.setTimeZone(TimeZone.getTimeZone("GMT")); System.out.println("GMT/UTC Time : " + df.format(date)); } }
Output:
Local Time: 2021 Feb 03 13:14:50 IST GMT/UTC Time : 2021 Feb 03 07:44:50 GMT
Leave a comment
You must login or register to add a new comment.