Java Time in GMT getGMTime()

Here you can find the source of getGMTime()

Description

Get the current GMT time for user notification.

License

Open Source License

Return

timestamp value as string.

Declaration

public static String getGMTime() 

Method Source Code

//package com.java2s;
/*//from   w ww  .j av  a2  s. co m
 * @(#) UtilsLib.java     version 1.0   24/5/2013
 *
 * Copyright (C) 2013 Institute for the Management of Information Systems, Athena RC, Greece.
 *
 * This library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.text.SimpleDateFormat;
import java.util.TimeZone;

public class Main {
    /**
     * Get the current GMT time for user notification.
     *
     * @return timestamp value as string.
     */
    public static String getGMTime() {
        SimpleDateFormat gmtDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        gmtDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));

        //Current Date Time in GMT
        return gmtDateFormat.format(new java.util.Date());
    }
}

Related

  1. getGMTDateString(Date date)
  2. getGMTDatetime(Date datetime)
  3. getGMTDatetimeFormat()
  4. getGmtFromTimeInMillis(String val)
  5. getGMTime()
  6. getGMTString(Date d)
  7. getGMTString(Date date, TimeZone tz)
  8. getGMTTime(Date localTime)
  9. getGMTTime(final Date date)