Java Timestamp Parse parseHeaderDate(String timestamp)

Here you can find the source of parseHeaderDate(String timestamp)

Description

Parses a formated date and time string in HTTP-Header date format and returns the time value.

License

Open Source License

Parameter

Parameter Description
timestamp the timestamp in HTTP-Header date format

Exception

Parameter Description
ParseException if parsing fails

Return

time value as long

Declaration

public static long parseHeaderDate(String timestamp) throws ParseException 

Method Source Code


//package com.java2s;
/*/*  ww w .ja  va 2 s  . co m*/
 * This library is part of OpenCms -
 * the Open Source Content Management System
 *
 * Copyright (c) Alkacon Software GmbH (http://www.alkacon.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * For further information about Alkacon Software GmbH, please see the
 * company website: http://www.alkacon.com
 *
 * For further information about OpenCms, please see the
 * project website: http://www.opencms.org
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Locale;

public class Main {
    /** The default format to use when formatting http headers. */
    protected static final DateFormat HEADER_DEFAULT = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz",
            Locale.US);

    /**
     * Parses a formated date and time string in HTTP-Header date format and returns the 
     * time value.<p>
     *  
     * @param timestamp the timestamp in HTTP-Header date format
     * @return time value as long
     * @throws ParseException if parsing fails
     */
    public static long parseHeaderDate(String timestamp) throws ParseException {

        return HEADER_DEFAULT.parse(timestamp).getTime();
    }
}

Related

  1. parse(java.sql.Timestamp timestamp)
  2. parseAsCassandraTimestamp(String dateString)
  3. parseDateTimeToTimestamp(String string)
  4. parseSnapshotTimestamp(final String tstamp)
  5. parseSQLiteTimestamp(String dd)
  6. parseStopTime(String timestamp, String timezone)
  7. parseTimestamp(Date date)