Java SQL Date Parse getSQLDateFromStr(String s)

Here you can find the source of getSQLDateFromStr(String s)

Description

Convert Date String into sql Date

License

Open Source License

Declaration


public static java.sql.Date getSQLDateFromStr(String s) 

Method Source Code

//package com.java2s;

import java.text.SimpleDateFormat;

public class Main {
    /**/*w  ww.j  av a  2 s.co  m*/
     * Convert Date String into sql Date
     */

    public static java.sql.Date getSQLDateFromStr(String s) {
        java.sql.Date dte = null;
        try {
            String str = s;
            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
            java.util.Date dt = formatter.parse(str);
            dte = new java.sql.Date(dt.getTime());
        } catch (Exception e) {
            e.printStackTrace();
        }

        return dte;
    }
}

Related

  1. getSQLDate(String dateString)
  2. getSqlDate(String dateString, String format)
  3. getSqlDate(String str)
  4. getSqlDateByShortStr(String dateStr)
  5. getSqlDateFromStr(DateFormat format, String s, boolean need_default)
  6. getSqlDateFromString(String dateAsString, String format)
  7. parse(String date)
  8. parseDate(final String dateString)
  9. parseDate(String date)