Android GMT Date Get getGMTDate()

Here you can find the source of getGMTDate()

Description

get GMT Date

License

Open Source License

Declaration

public static String getGMTDate() 

Method Source Code

//package com.java2s;
/**// w  w  w. j  a v  a 2  s. c  om
 * Copyright (c) 2012 The Wiseserc. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

import java.text.DateFormat;

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

public class Main {

    public static String getGMTDate() {
        return getGMTDate(new Date());
    }

    public static String getGMTDate(Date date) {
        if (date == null) {
            return null;
        }
        DateFormat dateFormat = new SimpleDateFormat(
                "E, dd MMM yyyy HH:mm:ss 'GMT'", Locale.ENGLISH);
        dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
        String dateStr = dateFormat.format(date);
        return dateStr;
    }
}

Related

  1. getGMTDate(Date date)
  2. getGMTDateFromString(String dateStr)
  3. getMillisGMT()
  4. millisToGMT(long millis)