Oracle Date Field Operations in java oracle operations, Date field is a headache, in fact, a careful study is not difficult to grasp. For example, the table book contains two fields: name varchar2 (20) // book name and buydate Date // purchase Date. You have created a database Connection conn; www.2cto.com method 1. Use java. SQL. Date to implement a simple Date in yyyy-mm-dd format. Java. SQL. Date does not support the time format. Do not use new java. SQL. Date (int year, int month, int date), because the time difference problem must be processed. PreparedStatement pstmt = conn. prepareStatement ("insert into book (name, buydate) values (?,?) "); Java. SQL. date buydate = java. SQL. date. valueOf ("2005-06-08"); pstmt. setString (1, "Java programming ideas"); pstmt. setDate (2, buydate when using pstmt.exe cute (); Method 2: Use java. SQL. timestamp. Do not use new Timestamp (....) preparedStatement pstmt = conn. prepareStatement ("insert into book (name, buydate) values (?,?) "); Java. SQL. timestamp buydate = java. SQL. timestamp. valueOf ("2004-06-08 05: 33: 99"); pstmt. setString (1, "Java programming ideas"); pstmt. setTimestamp (2, buydate when using pstmt.exe cute (); Method 3: Use the oracle to_date built-in function PreparedStatement pstmt = conn. prepareStatement ("insert into book (name, buydate) values (?, To_date (?, 'Yyyy-mm-dd hh24: mi: ss') "); String buydate =" 2004-06-08 05: 33: 99 "; pstmt. setString (1, "Java programming ideas"); pstmt. setString (2, buydate when using pstmt.exe cute (); www.2cto.com attached: oracle Date Format parameter description d: day of the week: the name of the day, with spaces filled with 9 Characters dd: the day of the month ddd: The day of the year dy: the abbreviation of the day iw: the week of the year in the ISO standard iyyy: the four-digit year of the ISO standard yyyy: four-digit year yyy, yy, y: the last three digits of the year, two digits, one digit hh: hour, 12 hours hh24: hour, 24 hours mi: minute ss: second mm: month mon: month abbreviated month: full name of the month w: the nth week of the month ww: the nth week of the year