Java SQL Date Parse getSqlDate(String str)

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

Description

get Sql Date

License

Apache License

Declaration

public static java.sql.Date getSqlDate(String str) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

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

public class Main {
    public static java.sql.Date getSqlDate(String str) {
        try {/*from  www.  ja  v  a2  s . co  m*/
            if (str == null || str.equals("")) {
                return null;
            }
            DateFormat df = new java.text.SimpleDateFormat("yyyy-MM-dd");
            java.util.Date tempDate = df.parse(str);
            return new java.sql.Date(tempDate.getTime());
        } catch (ParseException ex) {
            return null;
        }
    }
}

Related

  1. getSQLDate(String dateString)
  2. getSqlDate(String dateString, String format)
  3. getSqlDateByShortStr(String dateStr)
  4. getSqlDateFromStr(DateFormat format, String s, boolean need_default)
  5. getSQLDateFromStr(String s)
  6. getSqlDateFromString(String dateAsString, String format)