Oracle TIMESTAMP processing, oracletimestamp
Public class Test {
Private static final SimpleDateFormat FORMAT = new SimpleDateFormat ("yyyy-MM-dd HH: mm: dd ");
Public static void main (String [] args) throws SQLException {
Oracle. SQL. TIMESTAMP temp = new oracle. SQL. TIMESTAMP ();
System. out. println (convertOrclTimestemp2String (temp, null ));
}
Public static String convertOrclTimestemp2String (oracle. SQL. TIMESTAMP temp, String pattern) throws SQLException {
Java. SQL. Timestamp tt = (java. SQL. Timestamp) temp. toJdbc ();
If (StringUtils. isNotBlank (pattern )){
FORMAT. applyPattern (pattern );
}
Return FORMAT. format (new Date (tt. getTime ()));
}
}
Output result: 00:00:01
The timestamp display format of oracle
Alter session set nls_timestamp_format = 'yyyy-mm-dd hh24: mi: ss ';
SQL> create table wcy_t1 (f1 timestamp );
Table created.
SQL> insert into wcy_t1 values (systimestamp );
1 row created.
SQL> commit;
Commit complete.
SQL> select * from wcy_t1;
F1
---------------------------------------------------------------------------
16:46:06
Timestamp and date types in oracle
This type consists of java. util. Date and a separate millisecond value. Only integer seconds are stored in the java. util. Date component. Fractional seconds (in milliseconds) exist independently. The Timestamp. equals (Object) method never returns true when the Object is passed as an Object that is not a java. SQL. Timestamp instance, because the date millisecond component is unknown. Therefore, compared with the java. util. Date. equals (Object) method, the Timestamp. equals (Object) method is asymmetric. In addition, the hashcode method uses the underlying java. util. Date implementation and therefore does not include in its computing.
Considering the difference between the Timestamp class and the preceding java. util. Date class, we recommend that you do not regard the Timestamp value as an instance of java. util. Date. The inheritance relationship between Timestamp and java. util. Date actually refers to implementation inheritance, not type inheritance.