Java Hour Format formatHttpDate(Date date)

Here you can find the source of formatHttpDate(Date date)

Description

format Http Date

License

Open Source License

Declaration

public static String formatHttpDate(Date date) 

Method Source Code

//package com.java2s;
/**/*from w w  w .  jav a 2s .c  om*/
 * Logspace
 * Copyright (c) 2015 Indoqa Software Design und Beratung GmbH. All rights reserved.
 * This program and the accompanying materials are made available under the terms of
 * the Eclipse Public License Version 1.0, which accompanies this distribution and
 * is available at http://www.eclipse.org/legal/epl-v10.html.
 */

import java.text.DateFormat;

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

public class Main {
    private static final String DATE_FORMAT_RFC1123 = "EEE, dd MMM yyyy HH:mm:ss z";

    public static String formatHttpDate(Date date) {
        return createDateFormat(DATE_FORMAT_RFC1123).format(date);
    }

    private static DateFormat createDateFormat(String format) {
        DateFormat dateFormat = new SimpleDateFormat(format, Locale.ENGLISH);
        dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
        return dateFormat;
    }
}

Related

  1. formatHourTimeHToString(Date srcDate)
  2. formatHttpDate(Date d)
  3. formatHTTPDate(Date date)
  4. formatHttpDate(Date date)
  5. formatHttpDate(Date date)
  6. formatHTTPDate(Date pTime)
  7. formatInfo(String info)
  8. formatInternal(final Date date)
  9. formatInterval(long intervalMsec)