Here you can find the source of parseIso8601Date(String strDate)
Parameter | Description |
---|---|
strDate | a parameter |
public static Date parseIso8601Date(String strDate) throws ParseException
//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); } }