• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 14665
  • Last Modified:

timestamp with java

Hi all,

I am using Interbase 6 and 7.I can reproduce the problem in both versions of IB
I have columns of data type TIMESTAMP.

I have a java program for inserting records, it seems that the data that gets entered into these TIMESTAMP columns are only capturing the date.

here is the code below to convert java.util.Date to java.sql.Date to be used with a prepared statement.
i need it to capture the date and time.

    private java.sql.Date convert(java.util.Date d)
        java.sql.Date res = new java.sql.Date(new java.util.Date().getTime());

        if (d != null)
            res = new java.sql.Date(d.getTime());
        return res;

d that gets passed in is new java.util.Date(), i can see the long values when i am in the debugger
is there a setting that i need to set on the Interbase database?

setting the prepared statment as follows
ps.setDate(some pos, convert(new java.util.Date()));

pls help

1 Solution
Try this:

ps.setTimestamp(somePos, new Timestamp(new java.util.Date().getTime());
ahuenAuthor Commented:

found the same solution


Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now