Java implements the oracle method to insert the current time

  • 2020-04-01 03:43:47
  • OfStack

This article illustrates how Java implements oracle to insert the current time. Share with you for your reference. Specific analysis is as follows:

I'm doing an inser operation
To get the current time is stored in the database
It directly


ps.setDate(new java.util.Date());

But a conversion error will be reported

At this time should be


java.util.Date utilDate = new java.util.Date();
java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
ps.setDate(sqlDate );

It is ok

I hope this article has been helpful to your Java programming.


Related articles: