About Java, Oracle Time and Contact

xiaoxiao2021-03-06  72

SimpleDateFormat Formatter = New SimpleDateFormat ("YYYY-MM-DD HH: MM: SS"); string DateTime = formatter.format (new date ()); then I inserted into the corresponding time field through the SQL statement: ..... .to_date ('" datetime ",' YYYY-MM-DD HH24: MI: SS ') ...

But the prompt error: Missing Comma has solved the original brackets, FAINT, I can use INSERT TABLE XX (Date, ...) Values ​​when they are placed in the database. Java.util.date CurrentTime = new java.util.date (); java.sql.date currenttime2 = new java.sql.date (CURRENTTIME.GETTIME ()); PSTMT.SetDate (1, currenttime2); pay attention to In this way, the date is only until the day, and the time division may be 0 solution is java.util.date currenttime = new java.util.date (); pstmt.SetTimeStamp (1, new java.sql.timestamp (CurrentTime.gettime ())); This can be retained. Take the time field: rs.gettime (inc) Take the date: rs.getdate (color); Take the date and time: rs.gettimestamp (col); java.sql.timestamp time = result.getTimeStamp ("sysdate"); SimpleDateFormat LFORMAT = New SimpleDateFormat ("YYYY-MM-DD"); String DateStr = LFORMAT.FORMAT (TIME); (java.util.date) Result.GetObject ("Datefield")

转载请注明原文地址:https://www.9cbs.com/read-91932.html

New Post(0)