Here you can find the source of getTimeAndDateAtGMT()
private static String getTimeAndDateAtGMT()
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.TimeZone; public class Main { /**/* w w w .j a va 2 s .c o m*/ * This method returns the current time in GMT. * * @return current time in GMT */ private static String getTimeAndDateAtGMT() { String pattern = "MMMMM dd, yyyy; H:mm"; SimpleDateFormat simpleformat = new SimpleDateFormat(pattern); TimeZone tz = TimeZone.getTimeZone("GMT"); java.util.Calendar cal = Calendar.getInstance(tz); simpleformat.setCalendar(cal); String date = simpleformat.format(new Date()); // System.out.println(date + " GMT"); return date + " GMT"; } }