Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Java (new Date()).getTime() - java.util.Timestamp("select timestamp from dual").getTime() ???
On May 22, 4:34 pm, Joerg Weule <jwe..._at_arcor.de> wrote:
> Hello,
>
> I tried to retrieve a timestamp from my database independent from the
> local TZ environment variable. The ResultSet.getTimestamp(...).getTime()
> method should return the number of seconds after "1.1.1970 GMT" like
> (new Date()).getTime() .
>
> Is there any timestamp (current, local, sys, ...) to get the correct time?
>
> Thanks in advance
>
> Jörg
>
> --------------------------------------------------------
> export TZ=...
>
> run :
>
> PreparedStatement s = c.prepareStatement(
> "SELECT ?????????? FROM dual");
> ResultSet rs = s.executeQuery();
> rs.next();
> t3 = rs.getTimestamp(1,java.util.Calendar.getInstance());
> System.out.println(
> "Timestamp-Error:"
> +rs.getTimestamp(1).getTime()-(new Date().getTime());
> rs.close() ;
> s.close() ;
I do not code java so I have no idea if you can use this the way your post shows but the Oracle function current_timestamp returns a timestamp value equal to the current database time.
HTH -- Mark D Powell -- Received on Wed May 23 2007 - 18:59:28 CDT