Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Main {
    public static final SimpleDateFormat HTTP_DATE_FORMAT = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss");

    /**
     * Returns yesterday's date formatted according to the HTTP specification
     * standard date format.
     *
     * @return a formatted string.
     */
    public static String getExpiredHttpDateString() {
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.DAY_OF_YEAR, -1);

        return getHttpDateString(cal.getTime());
    }

    /**
     * Formats a Date according to the HTTP specification standard date format.
     *
     * @param date the Date to format.
     * @return a formatted string.
     */
    public static String getHttpDateString(Date date) {
        return HTTP_DATE_FORMAT.format(date) + " GMT";
    }
}