agora inbox for pljava-dev@postgresql.org  
help / color / mirror / Atom feed
[Pljava-dev] Function taking timestamp argument.
2+ messages / 0 participants
[nested] [flat]

* [Pljava-dev] Function taking timestamp argument.
@ 2007-09-13 10:11 
  2007-09-13 10:20 ` [Pljava-dev] Function taking timestamp argument. 
  0 siblings, 1 reply; 2+ messages in thread

From:  @ 2007-09-13 10:11 UTC (permalink / 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.










^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* [Pljava-dev] Function taking timestamp argument.
  2007-09-13 10:11 [Pljava-dev] Function taking timestamp argument. 
@ 2007-09-13 10:20 ` 
  0 siblings, 0 replies; 2+ messages in thread

From:  @ 2007-09-13 10:20 UTC (permalink / raw)

Forgot to mention.

I am using PLJava from CVS checked out this morning.
PostgreSQL 8.2 on Ubuntu Linux
Sun Java version 1.6.0_02


Peter Henderson.





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2007-09-13 10:20 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-09-13 10:11 [Pljava-dev] Function taking timestamp argument. 
2007-09-13 10:20 ` 

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