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:
    [color=blue]
    > 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?[/color]

    Yes, because it's a Date (date only). Try getTimestamp().
    Joe Weinstein at BEA

    [color=blue]
    >
    > Many thanks
    > SB
    >
    >
    >[/color]

    Comment

    • Spare Brain

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

      "Joe Weinstein" <joeNOSPAM@bea. com> wrote in message
      news:42003788.1 050606@bea.com. ..[color=blue]
      >
      >
      > Spare Brain wrote:
      >[color=green]
      > > Hi,
      > >
      > > I am observing a strange error with the time portion of the[/color][/color]
      java.sql.Date()[color=blue][color=green]
      > > 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[/color][/color]
      suggest?[color=blue]
      >
      > Yes, because it's a Date (date only). Try getTimestamp().
      > Joe Weinstein at BEA
      >
      >[color=green]
      > >
      > > Many thanks
      > > SB
      > >
      > >
      > >[/color]
      >[/color]

      That worked!!! Thanks Joe.
      SB


      Comment

      Working...