pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Java and PGSQL date question
3+ messages / 3 participants
[nested] [flat]

* Java and PGSQL date question
@ 1999-05-10 16:37 Adam H. Pendleton <apendleton@vgsinc.com>
  1999-05-10 18:04 ` Re: [INTERFACES] Java and PGSQL date question Thomas Lockhart <lockhart@alumni.caltech.edu>
  0 siblings, 1 reply; 3+ messages in thread

From: Adam H. Pendleton @ 1999-05-10 16:37 UTC (permalink / raw)
  To: pgsql-interfaces@hub.org

I am trying to pass a date from Java into a PostgreSQL database.  I am using
the DateFormat.parse() funcitonality to format the date.  However, the
database doesn't want to take it?  I looked at the PGSQL documentation and
it says that the default date type is postgresql date type, which is: Wed
Dec 17 07:37:16 1997 PST.  Java is sending the date in this format: Wed Dec
17 07:37:16 PST 1997.  How do I make this work.   Is it easier to change the
Java format or the PGSQL format?

Adam
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Si hoc legere scis nimium eruditionis habes.





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

* Re: [INTERFACES] Java and PGSQL date question
  1999-05-10 16:37 Java and PGSQL date question Adam H. Pendleton <apendleton@vgsinc.com>
@ 1999-05-10 18:04 ` Thomas Lockhart <lockhart@alumni.caltech.edu>
  0 siblings, 0 replies; 3+ messages in thread

From: Thomas Lockhart @ 1999-05-10 18:04 UTC (permalink / raw)
  To: Adam H. Pendleton <apendleton@vgsinc.com>; +Cc: pgsql-interfaces@hub.org

> I am trying to pass a date from Java into a PostgreSQL database.  I am using
> the DateFormat.parse() funcitonality to format the date.  However, the
> database doesn't want to take it?  I looked at the PGSQL documentation and
> it says that the default date type is postgresql date type, which is: Wed
> Dec 17 07:37:16 1997 PST.  Java is sending the date in this format: Wed Dec
> 17 07:37:16 PST 1997.  How do I make this work.   Is it easier to change the
> Java format or the PGSQL format?

postgres=> select 'Wed Dec 17 07:37:16 PST 1997'::datetime;
?column?                    
----------------------------
Wed Dec 17 15:37:16 1997 UTC
(1 row)

Looks good to me. Does this work from psql on your db? If so, then the
problem lies elsewhere...

                       - Tom

-- 
Thomas Lockhart				lockhart@alumni.caltech.edu
South Pasadena, California



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

* RE: [INTERFACES] Java and PGSQL date question
@ 1999-05-11 10:11 Peter Mount <petermount@it.maidstone.gov.uk>
  0 siblings, 0 replies; 3+ messages in thread

From: Peter Mount @ 1999-05-11 10:11 UTC (permalink / raw)
  To: Thomas Lockhart <lockhart@alumni.caltech.edu>; Adam H. Pendleton <apendleton@vgsinc.com>; +Cc: pgsql-interfaces@hub.org

I didn't see the original message, but the correct way to send Java
dates to psql is to use a PreparedStatement, and the setDate() method.

Formatting dates manually, and sending to a Statement may work, but then
you'll fall fowl of the DateStyle settings.

PS: I'm still testing some modifications to the date routines in the
driver.

--
Peter T Mount, IT Section
petermount@it.maidstone.gov.uk
Anything I write here are my own views, and cannot be taken as the
official words of Maidstone Borough Council

-----Original Message-----
From: Thomas Lockhart [mailto:lockhart@alumni.caltech.edu]
Sent: Monday, May 10, 1999 7:04 PM
To: Adam H. Pendleton
Cc: pgsql-interfaces@hub.org
Subject: Re: [INTERFACES] Java and PGSQL date question


> I am trying to pass a date from Java into a PostgreSQL database.  I am
using
> the DateFormat.parse() funcitonality to format the date.  However, the
> database doesn't want to take it?  I looked at the PGSQL documentation
and
> it says that the default date type is postgresql date type, which is:
Wed
> Dec 17 07:37:16 1997 PST.  Java is sending the date in this format:
Wed Dec
> 17 07:37:16 PST 1997.  How do I make this work.   Is it easier to
change the
> Java format or the PGSQL format?

postgres=> select 'Wed Dec 17 07:37:16 PST 1997'::datetime;
?column?                    
----------------------------
Wed Dec 17 15:37:16 1997 UTC
(1 row)

Looks good to me. Does this work from psql on your db? If so, then the
problem lies elsewhere...

                       - Tom

-- 
Thomas Lockhart				lockhart@alumni.caltech.edu
South Pasadena, California



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


end of thread, other threads:[~1999-05-11 10:11 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-05-10 16:37 Java and PGSQL date question Adam H. Pendleton <apendleton@vgsinc.com>
1999-05-10 18:04 ` Thomas Lockhart <lockhart@alumni.caltech.edu>
1999-05-11 10:11 RE: [INTERFACES] Java and PGSQL date question Peter Mount <petermount@it.maidstone.gov.uk>

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