Java Parse Date Pattern YYYY parse(String date)

Here you can find the source of parse(String date)

Description

Parses a textual representation of a timestamp into a numeric timestamp.

License

Open Source License

Parameter

Parameter Description
date a parameter

Exception

Parameter Description
ParseException if the <code>time</code> parameter does not conform to the expectedsyntax (see <code>FORMAT</code>).

Return

a numerical timestamp corresponding to the supplied date

Declaration

public static long parse(String date) throws ParseException 

Method Source Code


//package com.java2s;
/*//w ww .  j ava  2 s.  c om
 * Copyright (c) 2004-2005 Universite de Nantes (LINA)
 * Copyright (c) 2005-2006 France Telecom
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License version 2.1 as published by the Free Software Foundation.
 * 
 * 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.
 * 
 * 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
 *
 * Contact: Pierre-Charles David <pcdavid@gmail.com>
 */

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

public class Main {
    /**
     * The textual format used to represent timestamps. Conforms to ISO 8601.
     */
    private static final SimpleDateFormat FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");

    /**
     * Parses a textual representation of a timestamp into a numeric timestamp.
     * 
     * @param date
     * @return a numerical timestamp corresponding to the supplied date
     * @throws ParseException
     *             if the <code>time</code> parameter does not conform to the expected
     *             syntax (see <code>FORMAT</code>).
     */
    public static long parse(String date) throws ParseException {
        return FORMAT.parse(date).getTime();
    }
}

Related

  1. parse(String date)
  2. parse(String date)
  3. parse(String date)
  4. parse(String date)
  5. parse(String date)
  6. parse(String date)
  7. parse(String date)
  8. parse(String date)
  9. parse(String date)