Re: Java date format in select query

From: Nigel Thomas <nigel.cl.thomas_at_googlemail.com>
Date: Tue, 4 Nov 2008 17:14:45 +0000
Message-ID: <53258cd50811040914m2460a6a8ie4e0efe8586fb78f@mail.gmail.com>


2008/11/4 John Dunn <JDunn_at_sefas.com>

> A 3rd party process is passing a date in java.util.date format to my
> SQLPLUS script and I want to use it in a select statement
>
> Can the TO_DATE clause handle a java date? If so, whats the syntax?
>

Assuming that the string is produced with ToString() it should come out as

dow mon dd hh:mm:ss zzz yyyy
(of course there's nothing to stop a java date being serialised any way you like)

dow=day of week ('day' format in Oracle) zzz =timezone (eg PST - 'TZD' format in Oracle) hh = hour (ie HH24 in Oracle)
etc...

So you should be able to parse this easily enough into a timestamp, and then into a datetime. You could simply make your NLS_TIMESTAMP_TZ_FORMAT parameter the same as the java date format... or fiddle with the java format to make it match a standard Oracle timestamp format...

As it is being passed to a script, I presume it is being used as a literal?

Regards Nigel

--
http://www.freelists.org/webpage/oracle-l
Received on Tue Nov 04 2008 - 11:14:45 CST

Original text of this message