Java SQL Date Parse stringToSqlDate(String dateVal)

Here you can find the source of stringToSqlDate(String dateVal)

Description

This method is used to convert the date String in the format of "yyyy-MM-dd" to Sql Date

License

Open Source License

Parameter

Parameter Description
dateVal - string date value

Exception

Parameter Description
Exception an exception

Return

sqlDate

Declaration

public static java.sql.Date stringToSqlDate(String dateVal) throws Exception 

Method Source Code

//package com.java2s;

public class Main {
    /**/*w w  w  . j  a va 2s  . c  o  m*/
     * This method is used to convert the date String in the format of
     * "yyyy-MM-dd" to Sql Date
     * 
     * @param dateVal -
     *            string date value
     * @return sqlDate
     * @throws Exception
     */
    public static java.sql.Date stringToSqlDate(String dateVal) throws Exception {

        if (dateVal != null && !"".equals(dateVal)) {

            java.sql.Date sqlDate = java.sql.Date.valueOf(dateVal);
            return sqlDate;

        } else {
            return null;
        }

    }
}

Related

  1. stringToDate(String str)
  2. stringToDate(String str)
  3. StringToDateHMS(String str)
  4. stringToSqlDate(String data)
  5. stringToSqlDate(String date)
  6. stringToSQLDate(String pstrValue, String pstrDateFormat)
  7. stringToSqlDate(String str)
  8. StrToDate(String Formate, String date)
  9. strToDate(String str)