Java Parse Date parseDate(String str)

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

Description

Parses a date.

License

Open Source License

Parameter

Parameter Description
str String.

Return

The date, or null if syntax error.

Declaration


static public Date parseDate(String str) 

Method Source Code


//package com.java2s;
/*   Please see the license information at the end of this file. */

import java.util.*;

import java.text.*;

public class Main {
    /**   Date formatter for dates in format e.g. 02/06/02. */

    static private final SimpleDateFormat dateFormatter3 = new SimpleDateFormat("MM/dd/yy");

    /**   Parses a date.
     */*  ww w.j a  v  a  2 s.  c o m*/
     *   @param   str         String.
     *
     *   @return            The date, or null if syntax error.
     */

    static public Date parseDate(String str) {
        ParsePosition pos = new ParsePosition(0);
        Date result = dateFormatter3.parse(str, pos);
        if (result != null && pos.getIndex() < str.length())
            result = null;
        return result;
    }
}

Related

  1. parseDate(String srtDate, String pattern)
  2. parseDate(String str)
  3. parseDate(String str)
  4. parseDate(String str)
  5. parseDate(String str)
  6. parseDate(String str)
  7. parseDate(String str, boolean strict, String... parsePatterns)
  8. parseDate(String str, DateFormat df)
  9. parseDate(String str, Locale locale, String... parsePatterns)