Create java.sql.Date Using the java.sql.Date.valueOf() Method in Java

Description

The following code shows how to create java.sql.Date Using the java.sql.Date.valueOf() Method.

The java.sql.Date object's valueOf() method accepts a String, which must be the date in JDBC time escape format: YYYY-MM-DD.

Example


//  w w w  . j a v a 2  s  . c  om
  
public class Main {

  public static void main(String[] args) {

    String date = "2000-11-01";
    java.sql.Date javaSqlDate = java.sql.Date.valueOf(date);
    System.out.println(javaSqlDate);
    
  }

}

The code above generates the following result.





















Home »
  Java Tutorial »
    JDBC »




Batch
Binary Data
Database
Date Time
Insert
ResultSet
SQL
Statement
Stored Function
Table