Java Date ISO Parse parseIso8601Date(String strDate)

Here you can find the source of parseIso8601Date(String strDate)

Description

parse Iso Date

License

Open Source License

Parameter

Parameter Description
strDate a parameter

Return

the Date obtained when parsing the argument against pattern yyyy-MM-dd

Declaration

public static Date parseIso8601Date(String strDate) throws ParseException 

Method Source Code

//package com.java2s;
/**/*www  . ja  va 2  s .com*/
 *     This file is part of the Squashtest platform.
 *     Copyright (C) 2010 - 2016 Henix, henix.fr
 *
 *     See the NOTICE file distributed with this work for additional
 *     information regarding copyright ownership.
 *
 *     This 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 3 of the License, or
 *     (at your option) any later version.
 *
 *     this software 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 software.  If not, see <http://www.gnu.org/licenses/>.
 */

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

import java.util.Date;

public class Main {
    private static final String ISO_DATE = "yyyy-MM-dd";

    /**
     * @param strDate
     * @return the Date obtained when parsing the argument against pattern yyyy-MM-dd
     */
    public static Date parseIso8601Date(String strDate) throws ParseException {
        if (strDate == null) {
            return null;
        } else {
            return parseDate(strDate, ISO_DATE);
        }
    }

    private static Date parseDate(String strDatetime, String format) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.parse(strDatetime);
    }
}

Related

  1. parseISO8601Date(String dateString)
  2. parseISO8601Date(String dateString)
  3. parseIso8601Date(String dateString)
  4. parseISO8601Date(String encoded, Date fallback)
  5. parseISO8601Date(String s)
  6. parseISO8601DateString(String dateString)
  7. parseIso8601DateTimeOrDate(String datestr)
  8. parseISO8601String(String dateString)
  9. parseISO8601TimeAndDateString(String dateString)