[Pljava-dev] Function taking timestamp argument.

From: peter(dot)henderson at starjar(dot)com (Peter Henderson)
To:
Subject: [Pljava-dev] Function taking timestamp argument.
Date: 2007-09-13 10:11:03
Message-ID: 192172.261189678240899.JavaMail.root@starjar.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pljava-dev

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.

Responses

Browse pljava-dev by date

  From Date Subject
Next Message Peter Henderson 2007-09-13 10:20:46 [Pljava-dev] Function taking timestamp argument.
Previous Message Lucas Madar 2007-09-10 15:30:02 [Pljava-dev] Installing under freebsd