Java Parse Date ParseDate(String dateString)

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

Description

Parses a date object from a string representation.

License

Open Source License

Parameter

Parameter Description
dateString String representation of a date

Return

Date object

Declaration

public static Date ParseDate(String dateString) 

Method Source Code


//package com.java2s;
// it under the terms of the GNU General Public License as published by

import java.text.SimpleDateFormat;
import java.util.*;

public class Main {
    /** Parses a date object from a string representation.
     *//from w w w .j  av  a 2 s.c om
     * @param dateString String representation of a date
     * @return Date object
     */
    public static Date ParseDate(String dateString) {
        return ParseDate(dateString, "MM/dd/yyyy");
    }

    /** Parses a date object from a string representation using the specified date pattern.
     *
     * @param dateString String representation
     * @param datePattern Date pattern
     * @return Date object
     */
    public static Date ParseDate(String dateString, String datePattern) {
        try {
            SimpleDateFormat fmt = new SimpleDateFormat(datePattern);
            return fmt.parse(dateString);
        } catch (Exception ex) {
            return null;
        }
    }
}

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)