f



Java (new Date()).getTime() - java.util.Timestamp("select timestamp from dual").getTime() ???

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() ;
0
Joerg
5/22/2007 8:34:50 PM
comp.databases.oracle.misc 8436 articles. 1 followers. Post Follow

2 Replies
371 Views

Similar Articles

[PageSpeed] 24

On May 22, 4:34 pm, Joerg Weule <jwe...@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=F6rg
>
> --------------------------------------------------------
> export TZ=3D...
>
> run :
>
> PreparedStatement s =3D c.prepareStatement(
>     "SELECT  ?????????? FROM dual");
> ResultSet rs =3D s.executeQuery();
> rs.next();
> t3 =3D 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 --

0
Mark
5/23/2007 11:59:28 PM
On May 24, 3:59 am, Mark D Powell <Mark.Pow...@eds.com> wrote:
> On May 22, 4:34 pm, Joerg Weule <jwe...@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 ti=
me?
>
> > Thanks in advance
>
> > J=F6rg
>
> > --------------------------------------------------------
> > export TZ=3D...
>
> > run :
>
> > PreparedStatement s =3D c.prepareStatement(
> >     "SELECT  ?????????? FROM dual");
> > ResultSet rs =3D s.executeQuery();
> > rs.next();
> > t3 =3D 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 --

That's current time in session time zone. Database time is returned by
systimestamp. And to get it in UTC, you can select
sys_extract_utc(systimestamp) from dual:

SQL> alter session set time_zone=3D'America/New_York';

Session altered.

SQL> select current_timestamp, systimestamp,
sys_extract_utc(systimestamp) from
dual;

CURRENT_TIMESTAMP
-----------------------------
SYSTIMESTAMP
-----------------------------
SYS_EXTRACT_UTC(SYSTIMESTAMP)
-----------------------------
24.05.07 09:19:38,687000 AMERICA/NEW_YORK
24.05.07 17:19:38,687000 +04:00
24.05.07 13:19:38,687000

Note that sys_extract_utc() returns TIMESTAMP, not TIMESTAMP WITH TIME
ZONE. I suppose that you can then
ResultSet.getTimestamp(...).getTime() from this and it should match
Date.getTime(). Actually, current_timestamp and systimestamp should be
handled correctly, too, as they contain time zone information and it
can be used to convert them to UTC. I think you can use
ResultSet.getTimestamp(int columnIndex) for that, no need to supply
Calendar instance.

Regards,
   Vladimir M. Zakharychev
   N-Networks, makers of Dynamic PSP(tm)
   http://www.dynamicpsp.com

0
Vladimir
5/24/2007 1:37:31 PM
Reply:

Similar Artilces:

Urgent Requirement in """""""""""""NEW YORK""""""""""""""""
Hello Partners, Please find the requirement below. Please send the updated resume along with rate and contact no. REQ#1: Title : Java Developer ( Rating Project) Duration : 6 months Rate : open Location : NY strong java, WebLogic 9.2, Web Services, Oracle REQ#2: Title : Java Developer Duration : 4 months Rate : open Location : NY Strong java, SQL REQ#3: Title : VB.Net Consultant Location : NY Duration : 4 months Rate : open Primarily looking at someone who has Excel, VB.net a...

To "new" or not to "new" ...
Brand new to C++ and to wxWidgets as well... I'm still on the steep learning curve for both and for some reason it's not clear to me what the advantages/disadvantages to simply instantiating an object or creating a pointer to that new object with the "new" operator. Consider these 2 examples: (1) void Universal::OnToolClick( wxCommandEvent& event ) { wxString bgsString; bgsString = wxGetOsDescription(); wxMessageDialog* dlgbx = new wxMessageDialog(this, bgsString, "Universal", wxYES_NO); if (dlgbx->ShowModal() == wxID_YES) ...

Usage of the database "Oracle" vs. company "Oracle"
Hi, I am writing a document and normally I wouldn't give a second thought to saying such and such will run using a database such as Oracle. It occurred to me that Oracle is the name of the company, and that an Oracle database doesn't differentiate between what you and I think of daily as Oracle (eg. 9i, 10g, or "launched" but not "released" 11g), and Oracle Times Ten or Oracle Database Lite or Oracle Berkeley DB or some other database Oracle provides that I have forgotton about. Does just shorthand "Oracle" still refer to say 10g. I don't want to write Oracle 10g because then I am specifying a version which opens a can of worms elsewhere. Ideas anyone. Thank you Barry Barry Bulsara wrote: > Hi, I am writing a document and normally I wouldn't give a second > thought to saying such and such will run using a database such as > Oracle. > > It occurred to me that Oracle is the name of the company, and that an > Oracle database doesn't differentiate between what you and I think of > daily as Oracle (eg. 9i, 10g, or "launched" but not "released" 11g), > and Oracle Times Ten or Oracle Database Lite or Oracle Berkeley DB or > some other database Oracle provides that I have forgotton about. > > Does just shorthand "Oracle" still refer to say 10g. I don't want to > write Oracle 10g because then I am specifying a version which op...

+new Date("2012-03-21") and +new Date("2012/03/21") can differ by up to about 432e5
For those who had not noticed : it appears that the results from each line in +new Date("2012/01/21") & +new Date("2012-01-21") and +new Date("2012/07/21") & +new Date("2012-07-21") can differ by up to about 432e5, dependent on location. The former is almost required to, and traditionally does, give a midnight of local time. The latter seems to give (NaN or) a midnight of GMT. Could that be checked in other places, particularly away from winter time = GMT ? I imagine that in the route from ISO 860...

""""""""""""""""""""""ADD ME""""""""""""""""""""
Hi , Hope you are doing great. Please let me take this opportunity to introduce myself, Iam Karthik working with BhanInfo Inc, a NY based company. We have consultants on our bench on various technologies, my request is to add me to your distribution list and kindly do send me the requirements. i have the below list available 1. Mainframe 2. Java 3.. Financial Analyst 4. Data Architect If there is any vendor ship agreement which has to be signed then I would like to take an opportunity to represent my company and expect your cooperation... We look forward to build a ve...

"""""""""ADD ME""""""""""
Hi , Hope you are doing great. Please let me take this opportunity to introduce myself, Iam Karthik working with BhanInfoi Inc, a NY based company. We have consultants on our bench on various technologies, my request is to add me to your distribution list and kindly do send me the requirements. i have the below list available 1. Mainframe 2. Java 3.. Financial Analyst 4. Data Architect If there is any vendor ship agreement which has to be signed then I would like to take an opportunity to represent my company and expect your cooperation... ...

No more "Subject", "Date/Time" or "Size" headers/buttons in new mail (and other) folders
All of a sudden they disappeared: the "Subject", "Date/Time" or "Size" headers/buttons in my new mail (and other) folder preview are gone! Just the sender remains, and when new mail arrives it 'disappears' somewhere in the alphabetically sorted list in stead of ending up on top in the date-sorted list. I use V4.31 on XP, sofar I never had any major issues. PMail sometimes decides for a disabled SMTP server without warning when I'm on the road, but that's it. This one is a major issue. It has rendered my email almost unusable. All I can...

converting from "cooked" to "raw" oracle database
i'm working on a database which consists of datafiles in filesystems (referred to as cooked in some technical documents). i want to look at the performance difference with all the files raw i.e. using logical volumes to store the data. i know its possible to backup raw files using the dd command. what i'm interested in finding out/understanding is how to perform the opposite process i.e. convert from a 'cooked' to 'raw' storage system for an existing instance containing data. can i use a dd command to copy data from file to logical volume? is an export/import the only o...

Why is "select distinct" faster than "select" ?
Hi all, I have the following strange effect: The statement: select <some values> from <some tables> where <some join statements> and <some conditions> and value1a in (select value1b from table1 where <some conditions>) has a process time of more than 3 minutes. (tables are quite small, indices are properly set). The same statement with "select distinct" instead of "select": select distinct <some values> from <some tables> where <some join statements> and <some conditions> and value1a in (select distinct value1b fr...

"If then; if then;" and "If then; if;"
I have a raw data set which is a hierarchical file: H 321 s. main st P Mary E 21 F P william m 23 M P Susan K 3 F H 324 S. Main St I use the folowing code to read the data to creat one observation per detail(P) record including hearder record(H): data test; infile 'C:\Documents and Settings\retain.txt'; retain Address; input type $1. @; if type='H' then input @3 Address $12.; if type='P' then input @3 Name $10. @13 Age 3. @16 Gender $1.; run; but the output is not what I want: 1 321 s. main H 2 321 s. main P Mary E 21 F 3 321 s...

"or" and "and"
Hi, I'm just getting to discover ruby, but I find it very nice programming language. I just still don't understand how the "or" and "and" in ruby... I was playing with ruby and for example made a def to print Stem and Leaf plot (for those who didn't have a statistics course or slept on it, e.g. http://cnx.org/content/m10157/latest/) Here is the Beta version of it: class Array def n ; self.size ; end def stem_and_leaf(st = 1) # if st != (2 or 5 or 10) then ; st = 1 ; end k = Hash.new(0) self.each {|x| k[x.to_f] += 1 } k = k.sort{|a, b| a[0].to_f <=&g...

about "++" and "--"
why this program snippet display "8,7,7,8,-7,-8" the program is: main() { int i=8; printf("%d\n%d\n%d\n%d\n%d\n%d\n",++i,--i,i++,i--,-i++,-i--); } > why this program snippet display "8,7,7,8,-7,-8" Ask your compiler-vendor because this result is IMHO implementation-defined. Check this out: http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.15 http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.16 Regards, Irina Marudina fxc123@gmail.com wrote: > why this program snippet display "8,7,7,8,-7,-8&q...

"/a" is not "/a" ?
Hi everybody, while testing a module today I stumbled on something that I can work around but I don't quite understand. >>> a = "a" >>> b = "a" >>> a == b True >>> a is b True >>> c = "/a" >>> d = "/a" >>> c == d True # all good so far >>> c is d False # eeeeek! Why c and d point to two different objects with an identical string content rather than the same object? Manu Emanuele D'Arrigo wrote: >>>> c = "/a" >>>&...

"my" and "our"
Hi, while testing a program, I erroneously declared the same variable twice within a block, the first time with "my", the second time with "our": { my $fz = 'VTX_Link'; .... ( around 200 lines of code, all in the same block) our $fz = 'VTX_Linkset'; ... } So the initial contents of the $fz declared with "my" is lost, because "our" creates a lexical alias for the global $fz, thus overwriting the previous "my" declaration. It was my error, no question. But I wonder why Perl doesn't mention this - even with "use s...

"out" and "in out"
Hi i found the following explaination: In Ada, "in" parameters are similar to C++ const parameters. They are effectively read-only within the scope of the called subprogram. Ada "in out" parameters have a reliable initial value (that passed in from the calling subprogram) and may be modified within the scope of the called procedure. Ada "out" parameters have no reliable initial value, but are expected to be assigned a value within the called procedure. What does "have no reliable initial value" mean when considering the "out" parameter? By c...

why "::", not "."
Why does the method of modules use a dot, and the constants a double colon? e.g. Math::PI and Math.cos -- Posted via http://www.ruby-forum.com/. On Oct 26, 2010, at 01:48 , Oleg Igor wrote: > Why does the method of modules use a dot, and the constants a double > colon? > e.g. > Math::PI and Math.cos For the same reason why inner-classes/modules use double colon, because = they're constants and that's how you look up via constant namespace. Math::PI and ActiveRecord::Base are the same type of lookup... it is = just that Base is a module and PI is a float....

"new" vs "new class"
I have come accross a piece of C++ code with the construct: MyClass *c = new class MyClass(); Is there a difference between this and: MyClass *c = new MyClass(); ? Thank you. "dpr" <virtualway@virtualway.com.br> wrote in message news:c0feu8$hoc$1@news-reader4.wanadoo.fr... | I have come accross a piece of C++ code with the construct: | | MyClass *c = new class MyClass(); | | Is there a difference between this and: | | MyClass *c = new MyClass(); | | ? No. Actually, this is not about "new" and "new class", but about "MyClass" or "cl...

Urgent Requirement for """""""""""""""INFORMATICA DEVELOPER"""""""""""""
Hello Partners, How are you ? Please find the requirements below. Title: Database/ETL Developer Duration: 6 months Location: NY Exp: 7+ Locals preferred Database/ETL requirements (Mandatory) Candidate must have worked with financial instruments, preferably Mutual Funds but, Equities are also ok. PL/SQL - packages, Stored procs, Functions, Aggregate functions, Pipelined Functions Informatica 8.6 - especially complex mappings, complex maplets, complex workflows, transformations Oracle 10g/11g Unix/Linux shell scripting ...

Urgent need """""""""""INFORMATICA DEVELOPER"""""""""""""
Hello Partners, How are you ? Please find the requirements below. Title: Database/ETL Developer Duration: 6 months Location: NY Exp: 7+ Locals preferred Database/ETL requirements (Mandatory) Candidate must have worked with financial instruments, preferably Mutual Funds but, Equities are also ok. PL/SQL - packages, Stored procs, Functions, Aggregate functions, Pipelined Functions Informatica 8.6 - especially complex mappings, complex maplets, complex workflows, transformations Oracle 10g/11g Unix/Linux shell scripting Database/ETL requirements (Optional) Data warehousing experience Threading and job concepts in 10g/11g Cost based Optimizer concepts in 10g/11g Must : Experience with XML files and partitioning concepts in Oracle, Collections, Material Views Note : No phone calls please. : send Resumes to karthik@bhaninfo.com Thanks & Regards Karthik BhanInfo karthik@bhaninfo.com ...

"In" "Out" and "Trash"
I just bought a new computer and I re-installed Eudora Light on my new computer. But when I open Eudora, the "In", "Out" and "Trash" links are not on the left side of the screen the way they were on my old computer. How can I get these links back on the left side of the screen? Thank you. On 25 Mar 2007 09:49:22 -0700, "abx" <abfunex@yahoo.com> wrote: >I just bought a new computer and I re-installed Eudora Light on my new >computer. But when I open Eudora, the "In", "Out" and "Trash" links >are ...

Does it need a ";" at the very after of "if" and "for"
write code like: int main(void) { int a=10; if(a<20) {} } Compiler ok on dev-cpp . don't we have to add a ";" after if statement? marsarden said: > write code like: > > int main(void) > { > int a=10; > if(a<20) > {} > } > > Compiler ok on dev-cpp . don't we have to add a ";" after if > statement? The syntax for 'if' is: if(expression) statement There is no semicolon after the ) but before the statement. The statement is either a normal statement (which can be empty), ending in a semicolon:- if(expr) ...

A problem about "[ ]" "( )" "="
I want to read several images saved in a director,and give them to I1,I2 ,I3....,using the following codes: filelist=dir(['c:\MATLAB701\work\...\*.jpg']); for i=1 :length(filelist) I=imread(fullfile('c:\MATLAB701\work\...',filelist(i).name)); end; but failed. Then I used I(i)=imread... ,still failed. How could I do? "John" <mailofww@126.com> wrote in message news:ef19e12.-1@webx.raydaftYaTP... >I want to read several images saved in a director,and give them to > I1,I2 ,I3....,using the following codes: > filelist=dir(['c:\MATLAB701\work\.....

[New Yanoff] crashes if "scoring" is set in "Misc Prefs"!
If you are experiencing crashes when entering any NG, please make sure that scoring is OFF (unchecked). This is being investigated and will be fixed in 2.2 and released ASAP! ...

"ODBC Bind Timestamp as Date" where has it gone ?
hello everyboby, can anybody help me with the following issue ? i administer a Terminal Server that we are migrating to W2K3. Now a days the Terminam Server is running NT with Orcal 9 Client and ODBC 9=2E2.06 with is O.K. The Problem : the new box is running W2K3 with Oracle 10 client. and Odbc 10.1.0.2.0. We use a Access Aplication with stores the Data on Oracle. in the Old Box the ODBC has the possibility to set an Option unter Workarounds called " bind Timestamp as Date". In the new Box i can=B4t find this Option. This Option has big impact on the Performance. The Special Query...

oracle datatype &quot;timestamp&quot;
Hi, &nbsp; does anybody know how to handle the oracle "timestamp"-datatype in LabView. &nbsp; I connect to the database by the "microsoft OLE DB Provider for Oracle". This one does not support this datatype. So I'm going to change to the oracle OLE-driver. &nbsp; &nbsp; Lorand Hi Lorand, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; This may be a "long-shot", but if the Oracle "timestamp" is the same format as the 8-byte "datetime" used&nbsp;in MS Access, and MS SQL, then it can be converted into a float meaning da...

Web resources about - Java (new Date()).getTime() - java.util.Timestamp("select timestamp from dual").getTime() ??? - comp.databases.oracle.misc

Resources last updated: 2/18/2016 10:27:08 PM