Java SQL Date Get getDate(String year, String month, String day)

Here you can find the source of getDate(String year, String month, String day)

Description

get Date

License

Apache License

Declaration

public static java.sql.Date getDate(String year, String month, String day) 

Method Source Code

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

import java.text.SimpleDateFormat;

public class Main {

    public static java.sql.Date getDate(String year, String month, String day) {
        java.sql.Date result = null;
        try {/*  w  w  w.j  a  v a 2  s  . c om*/
            String str = year + "-" + month + "-" + day;
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
            java.util.Date date1 = dateFormat.parse(str);
            result = new java.sql.Date(date1.getTime());
        } catch (Exception e) {
            System.out.println("Exception " + e);
        }
        return result;
    }
}

Related

  1. getDate(String format)
  2. getDate(String pattern)
  3. getDate(String strDate)
  4. getDate(String theDateStr, int days)
  5. getDate(String value)
  6. getDate(Timestamp establishdate)
  7. getDate(Timestamp timestamp)
  8. getDate(Timestamp timestamp)
  9. getDate(Timestamp ts)