Java Date GMT Format formatGMT(Date date, String parttern)

Here you can find the source of formatGMT(Date date, String parttern)

Description

format GMT

License

LGPL

Declaration

public static String formatGMT(Date date, String parttern) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.text.SimpleDateFormat;

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

public class Main {
    private static final TimeZone GMT = TimeZone.getTimeZone("GMT");

    public static String formatGMT(Date date, String parttern) {
        if (date == null) {
            return "";
        }/*from   ww  w  .j av  a  2s. c  o m*/
        if (parttern == null || parttern.equals("")) {
            return "";
        }
        SimpleDateFormat formater = new SimpleDateFormat(parttern, Locale.ENGLISH);
        formater.setTimeZone(GMT);
        return formater.format(date);
    }

    public static String format(Date date, String parttern) {
        if (date == null) {
            return "";
        }
        if (parttern == null || parttern.equals("")) {
            return "";
        }
        SimpleDateFormat formater = new SimpleDateFormat(parttern, Locale.ENGLISH);
        return formater.format(date);
    }
}

Related

  1. formatDateTimeGMT(Date date)
  2. formatGMT(Date date)
  3. formatGmtDate(Date date)
  4. formatGMTDate(Date gmtTime, int offset)
  5. getDefaultID2GMT()
  6. getFormattedGMTDate(long timestamp)