Conversion of Date type in sql

1. Correspondence between database type and java type

Date-->java.sql.Date

Time-->java.sql.Time

TimeStamp-->java.sql.TimeStamp

2. Time type conversion

1. All contents in the java.sql package cannot appear in the domain object (domain), that is, the java.sql.Date type cannot be used

  But!!! ResultSet.getDate() and PreparedStatement.setDate(int,Date) use java.sql.Date type

2.java.sql.Date Time TimeStamp----->java.util.Date

 Just convert directly, because java.util.Date is their parent class

3.java.util.Date----->java.sql.Date Time TimeStamp

 Convert the millisecond value under util to the long type of millisecond value, and use the millisecond value to create the millisecond value under sql

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324622675&siteId=291194637