Here you can find the source of parseDate(String dateString)
Date
class from dateString
.
Parameter | Description |
---|---|
dateString | a parameter |
Parameter | Description |
---|---|
RuntimeException | is dateString is invalid |
public static Date parseDate(String dateString)
//package com.java2s; /*//from www . j a va 2 s. c om * (c) Kitodo. Key to digital objects e. V. <contact@kitodo.org> * * This file is part of the Kitodo project. * * It is licensed under GNU General Public License version 3 or later. * * For the full copyright and license information, please read the * GPL3-License.txt file that was distributed with this source code. */ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { /** Utility method to create a <code>Date</code> class from <code>dateString</code>. @param dateString @return Date @throws RuntimeException is dateString is invalid */ public static Date parseDate(String dateString) { try { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MMM-dd"); return sdf.parse(dateString); } catch (ParseException pe) { throw new RuntimeException("Not a valid date: " + dateString + ". Must be of YYYY-MMM-DD format."); } } }