Java HTTP Date getHTTPDate()

Here you can find the source of getHTTPDate()

Description

get the date according to the HTTP standard

License

Open Source License

Return

the current date

Declaration

public static String getHTTPDate() 

Method Source Code

//package com.java2s;
/**********************************************************************
Copyright (c) 2010 Erik Bengtson and others. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at/*from w w w  .j  a  v  a 2s . co  m*/
    
http://www.apache.org/licenses/LICENSE-2.0
    
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
    
Contributors:
...
**********************************************************************/

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

public class Main {
    /**
     * get the date according to the HTTP standard
     * @return the current date
     */
    public static String getHTTPDate() {
        DateFormat httpDateFormat = new SimpleDateFormat("EEE', 'dd' 'MMM' 'yyyy' 'HH:mm:ss' 'Z", Locale.ENGLISH);
        httpDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
        return httpDateFormat.format(new Date());
    }
}

Related

  1. getHttpDate()
  2. gethttpDate()
  3. getHttpDate()
  4. getHttpDate(int days)
  5. getHttpDate(long l)
  6. getHttpDate(String date)
  7. getHttpDate(String value)