Java Parse Date parseDate(String dateString)

Here you can find the source of parseDate(String dateString)

Description

Utility method to create a Date class from dateString.

License

Open Source License

Parameter

Parameter Description
dateString a parameter

Exception

Parameter Description
RuntimeException is dateString is invalid

Return

Date

Declaration

public static Date parseDate(String dateString) 

Method Source Code

//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.");
        }
    }
}

Related

  1. parseDate(String dateString)
  2. ParseDate(String dateString)
  3. parseDate(String dateString)
  4. parseDate(String dateString)
  5. parseDate(String dateString)
  6. parseDate(String dateString)
  7. parseDate(String dateString)
  8. parseDate(String dateString)
  9. parseDate(String dateString, Locale locale)