Java Date GMT Format getTimeAndDateAtGMT()

Here you can find the source of getTimeAndDateAtGMT()

Description

This method returns the current time in GMT.

License

Open Source License

Return

current time in GMT

Declaration

private static String getTimeAndDateAtGMT() 

Method Source Code

//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";
    }
}

Related

  1. getDefaultID2GMT()
  2. getFormattedGMTDate(long timestamp)
  3. getNewGmtSimpleDateFormat(String format)
  4. getStringBaseGMT(Date date, String timezone)
  5. getThreadLocalGMTDateFormat(final String format)
  6. getTzToGmt(String dateStr, String dateFormat, String beforeTimeZone, String afterTimeZone)
  7. parseDate(String gmtTimeString)
  8. parseGMT(String gmtTime)
  9. parseGMTDatetime(String str)