1. The insert format is.
<Property name = "artAddTime" type = "java. util. Date">
<Column name = "ART_ADD_TIME" length = "7" not-null = "true"/>
</Property>
/**
* Write a time Method
*/
Public staticStringgetStringDate (){
Date d = new Date ();
SimpleDateFormat sdf = new SimpleDateFormat ("yyyy-MM-dd ");
Return sdf. format (d );
}
Insert:
Art. setArtAddTime (java. SQL. Date. valueOf (new TimeUtil (). getStringDate ()));
Dao. save (art );
="
Art. setArtAddTime (java. SQL. Date. valueOf ("2009-12-12 "));
However, the output value in the Java background is as follows: 00:00:00. 0
2
Insert hours, minutes, And seconds
<Property name = "artAddTime" type = "timestamp"> Date is also supported.
<Column name = "ART_ADD_TIME" not-null = "true"/>
</Property>
Art. setArtAddTime (java. SQL. Timestamp. valueOf (new TimeUtil (). getStringDate ("yyyy-MM-dd HH: mm: ss ")));
Output: 2010-12-1223:49:48. 0 Java output is still one more bit
3. If Oracle is 10 Gb, skip the above steps.
<Property name = "artAddTime" type = "timestamp"> Date is also supported.
<Column name = "ART_ADD_TIME" not-null = "true"/>
</Property>
Art. setArtAddTime (new Date ());
Out: 23:49:48. 0