agora inbox for pljava-dev@postgresql.org  
help / color / mirror / Atom feed
Subject: [Pljava-dev] Function taking timestamp argument.
Date: Thu, 13 Sep 2007 11:11:03 +0100
Message-ID: <192172.261189678240899.JavaMail.root@starjar.com> (raw)

Hi folks

I think there is a bug converting from Postgres timestamps to java time 
stamps.

I have a java function,

     public static BigDecimal calculateTotal(int accountId,
             java.sql.Timestamp startDate, java.sql.Timestamp endDate,
             boolean includeChildren)
     {
         BigDecimal result = BigDecimal.ZERO;

         java.util.Date now = new java.util.Date();

Logger.getAnonymousLogger().log(Level.WARNING,
         String.format("calculateTotal " +
         "accountId=%d startDate=%tD endDate=%tD includeChildren=%b " +
         "startDate.getTime()=%d now=%tD now.getTime()=%d",
         accountId, startDate, endDate, includeChildren,
         startDate.getTime(), now, now.getTime() )
         );



Which prints out

2007-09-13 11:09:22 BST WARNING:  13 Sep 07 11:09:22 
com.starjar.starjarenterprise.postgres.AccountTotal calculateTotal 
accountId=10026
startDate=10/04/77
endDate=01/21/78
includeChildren=false
startDate.getTime()=244785357000
now=09/13/07
now.getTime()=1189678162445


when called from SQL via

SELECT accounttotal(10026,
   CURRENT_TIMESTAMP,
   timestamp '2008-01-01 00:00', FALSE );



Notice the java log message.
It thinks the current time as passed in from SQL is 10/04/77 with a long 
of 244784200000
where as java thinks the current time long is 1189677005798


Is this a bug in my code (most likely)? a bug in pljava, or a bug in the 
way i am calling the function?



Regards


Peter Henderson.










view thread (2+ messages)  latest in thread

Message-ID: <192172.261189678240899.JavaMail.root@starjar.com>
Permalink:  ../192172.261189678240899.JavaMail.root@starjar.com/
Also on:    postgresql.org/message-id/192172.261189678240899.JavaMail.root@starjar.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 using the --to and --cc options:
  reply via email

  To: pljava-dev@postgresql.org
  Subject: Re: [Pljava-dev] Function taking timestamp argument.
  In-Reply-To: <192172.261189678240899.JavaMail.root@starjar.com>

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

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