Java Parse Date parseDate(String date, String format)

Here you can find the source of parseDate(String date, String format)

Description

parse Date

License

Open Source License

Declaration

public static Date parseDate(String date, String format) 

Method Source Code

//package com.java2s;
/**//from  w w w  .j  a v a 2  s.  c  om
 * Mule Google Api Commons
 *
 * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 *
 * The software in this package is published under the terms of the CPAL v1.0
 * license, a copy of which has been included with this distribution in the
 * LICENSE.txt file.
 */

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    public static Date parseDate(String date, String format) {
        DateFormat df = new SimpleDateFormat(format);
        try {
            return df.parse(date);
        } catch (ParseException e) {
            throw new IllegalArgumentException(
                    String.format("Could not parse date %s with format %s", date, format));
        }
    }
}

Related

  1. parseDate(String date)
  2. parseDate(String date)
  3. parseDate(String date, Locale locale)
  4. parseDate(String date, String expression)
  5. parseDate(String date, String format)
  6. parseDate(String date, String format)
  7. parseDate(String date, String format)
  8. parseDate(String date, String format)
  9. parseDate(String date, String pattern)