pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Greg Markham <gmarkham@markhamdirect.com>
To: Oliver Jowett <oliver@opencloud.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Timestamp Question
Date: Sun, 11 Jul 2004 15:54:27 -0500
Message-ID: <40F1A903.9040000@markhamdirect.com> (raw)
In-Reply-To: <40F15284.2090905@opencloud.com>
References: <40F012E4.3000001@markhamdirect.com>
	<40F15284.2090905@opencloud.com>

Oliver Jowett wrote:

> Greg Markham wrote:
>
>> I have searched the archives and not found and answer to this question:
>>
>> I am trying to use a Java Timestamp object to create a Postgresql 
>> Timestamp(6) field.  I can insert a Timestamp but it only goes to the 
>> millisecond(2004-07-10 12:59:59.123) I need it to the microsecond 
>> (2004-07-10 12:59:59.123456).  Is there a way to do this?
>
>
> From a quick look at the driver code, it appears to support nanosecond 
> precision in Timestamps.
>
> What exactly is the problem you see? Can you provide a testcase?
>
> -O
>
Timestamp myTs = new Timestamp(System.currentTimeMillis());

PreparedStatement myStatement = con.prepareStatement("insert into 
mytable (myID, myTimestamp) values (?,?));
myStatement.setString(1, "4451234578521");
myStatement.setTimestamp(2, myTs);
myStatement.execute();

Data that get inserted is:

4451234578521  2004-07-11 15:34:26.234

When I create a timestamp using the system.currentTimeMillis it just 
doesn't create a timestamp that has the precision I want.  I want the 
timestamp out past the millisecond and out to the microsecond like 
2004-07-11 15:34:26.274123.  How would I use the timestamp object to get 
to that precision?  Do I have to use a JNI call?

- Greg Markham





view thread (14+ messages)  latest in thread

Message-ID: <40F1A903.9040000@markhamdirect.com>
Permalink:  ../40F1A903.9040000@markhamdirect.com/
Also on:    postgresql.org/message-id/40F1A903.9040000@markhamdirect.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: gmarkham@markhamdirect.com, oliver@opencloud.com
  Subject: Re: Timestamp Question
  In-Reply-To: <40F1A903.9040000@markhamdirect.com>
  References: <40F012E4.3000001@markhamdirect.com> <40F15284.2090905@opencloud.com> <40F1A903.9040000@markhamdirect.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox