1 Reply Latest reply on Apr 12, 2004 9:10 AM by sesques

    oracle date format

    doshiaj Newbie

      I have a table in oracle(8i) which contains a column with type DATE. If I want to insert something in this column through CMP, and I use java.sql.Timestamp for this column, it works perfectly. But if I retrieve the value of this field through CMP, it gives the Timestamp object whose format is quite different from the regular Timestamp object.

      The timestamp object returned from the CMP is :
      4-04-10 10:00:00.0
      And the timestamp object created from system time, - new java.sql.Timestamp( System.currentTimeMillis() ) is
      2004-04-12 17:26:24.03

      Plus, if I try to get the milliseconds from the Timestamp object returned from the CMP, it prints a large negative value.

      In my application, I want to compare the timestamp object created from the current system time with the one returned from the CMP bean.

      What should be the solution to this?

        • 1. Re: oracle date format
          sesques Novice

          the java.sql.Timestamp class is not meant to be type-compatibly with
          java.util.Date (even though it inherits from it it is only meant to be
          considered as implementation inheritance).
          So you have two solutions:
          - 1 Use DateFormat or SimpleDateFormat format and parse methods to convert to the correct format but you will loose milliseconds.
          - 2 use a raw(8) instead of DATE