Java Date Parse convertStringToDate(String str)

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

Description

convert String To Date

License

Open Source License

Parameter

Parameter Description
str a parameter

Declaration

public static Date convertStringToDate(String str) 

Method Source Code

//package com.java2s;

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

import java.util.Date;

public class Main {
    /**/*  w w  w.  j ava 2  s . co m*/
     * @param str
     * @return
     */
    public static Date convertStringToDate(String str) {
        Date returnDate = null;
        DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
        try {
            if (str != null) {
                returnDate = df.parse(str);
            }
        } catch (ParseException pe) {
            returnDate = new Date();
        }
        return returnDate;
    }
}

Related

  1. convertStringToDate(String dateTime)
  2. convertStringToDate(String dateTime)
  3. convertStringToDate(String dt)
  4. convertStringToDate(String input)
  5. convertStringToDate(String s)
  6. convertStringToDate(String str, String pattern)
  7. convertStringToDate(String str_date)
  8. convertStringToDate(String strDate)
  9. convertStringToDate(String strDate, String parseFormat)