Can you help me with JDBC getDate() error?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Spare Brain

    Can you help me with JDBC getDate() error?

    Hi,

    I am observing a strange error with the time portion of the java.sql.Date()
    when using resultSet.getDa te() - it always seems to show 12:00:00.

    The following code prints 2004-10-27 11:00:00.0

    String dtStr = resultset.getSt ring("PROMISEDA TE");
    System.out.prin tln(dtStr);

    The following code prints 2004-10-27 12:00:00
    java.util.Date dt = resultset.getDa te("PROMISEDATE ");
    System.out.prin tln(new SimpleDateForma t("yyyy-MM-dd
    hh:mm:ss").form at(dt));

    Any clue why the getDate screws up the time? Any remedies you may suggest?

    Many thanks
    SB



  • Joe Weinstein

    #2
    Re: Can you help me with JDBC getDate() error?



    Spare Brain wrote:
    Hi,
    >
    I am observing a strange error with the time portion of the java.sql.Date()
    when using resultSet.getDa te() - it always seems to show 12:00:00.
    >
    The following code prints 2004-10-27 11:00:00.0
    >
    String dtStr = resultset.getSt ring("PROMISEDA TE");
    System.out.prin tln(dtStr);
    >
    The following code prints 2004-10-27 12:00:00
    java.util.Date dt = resultset.getDa te("PROMISEDATE ");
    System.out.prin tln(new SimpleDateForma t("yyyy-MM-dd
    hh:mm:ss").form at(dt));
    >
    Any clue why the getDate screws up the time? Any remedies you may suggest?
    Yes, because it's a Date (date only). Try getTimestamp().
    Joe Weinstein at BEA

    >
    Many thanks
    SB
    >
    >
    >

    Comment

    • Spare Brain

      #3
      Re: Can you help me with JDBC getDate() error?

      "Joe Weinstein" <joeNOSPAM@bea. comwrote in message
      news:42003788.1 050606@bea.com. ..
      >
      >
      Spare Brain wrote:
      >
      Hi,

      I am observing a strange error with the time portion of the
      java.sql.Date()
      when using resultSet.getDa te() - it always seems to show 12:00:00.

      The following code prints 2004-10-27 11:00:00.0

      String dtStr = resultset.getSt ring("PROMISEDA TE");
      System.out.prin tln(dtStr);

      The following code prints 2004-10-27 12:00:00
      java.util.Date dt = resultset.getDa te("PROMISEDATE ");
      System.out.prin tln(new SimpleDateForma t("yyyy-MM-dd
      hh:mm:ss").form at(dt));

      Any clue why the getDate screws up the time? Any remedies you may
      suggest?
      >
      Yes, because it's a Date (date only). Try getTimestamp().
      Joe Weinstein at BEA
      >
      >

      Many thanks
      SB

      >
      That worked!!! Thanks Joe.
      SB


      Comment

      Working...