Thread: I can't cast java.util.Date to oracle.jbo.domain.Date


Permlink Replies: 9 - Pages: 1 - Last Post: Jul 9, 2009 7:41 AM Last Post By: Natalie Koyokina
user470474

Posts: 2
Registered: 12/01/05
I can't cast java.util.Date to oracle.jbo.domain.Date
Posted: Dec 1, 2005 11:23 AM
Click to report abuse...   Click to reply to this thread Reply
Hi, i have a variable "pippo" type java.util.Date formatted like (dd-MM-YYYY hh:mm:ss)
and I want insert in my Database where the field is Date type(oracle.jbo.domain.Date)
in the same format(dd-MM-YYYY hh:mm:ss).
I try to convert "pippo" but the result is formatted(dd-MM-YYYY hh:mm:ss).

Thank's a lot yours time and i'm very sorry for my easy english

Bye Luca
Steve Stogner

Posts: 86
Registered: 10/07/05
Re: I can't cast java.util.Date to oracle.jbo.domain.Date
Posted: Dec 1, 2005 12:20 PM   in response to: user470474 in response to: user470474
Click to report abuse...   Click to reply to this thread Reply
java.util.Date utilDate = (java.util.Date)pippo;
java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
oracle.jbo.domain.Date jboDate = new oracle.jbo.domain.Date(sqlDate);
user470474

Posts: 2
Registered: 12/01/05
Re: I can't cast java.util.Date to oracle.jbo.domain.Date
Posted: Dec 2, 2005 12:34 AM   in response to: Steve Stogner in response to: Steve Stogner
Click to report abuse...   Click to reply to this thread Reply
Thank you very much for your reply but I just try this solutions and the result is:

UTIL-->Fri Dec 02 09:19:12 CET 2005
SQL-->2005-12-02
JBO-->2005-12-02

but i want this

UTIL-->Fri Dec 02 09:19:12 CET 2005
SQL-->Fri Dec 02 09:19:12 CET 2005
JBO-->Fri Dec 02 09:19:12 CET 2005

because i use the date field how a key in my table and I need the time(hh:mm:ss)

thank's a lot

bye Luca
rengo.Java

Posts: 12
Registered: 05/15/06
Re: I can't cast java.util.Date to oracle.jbo.domain.Date
Posted: Jan 15, 2007 7:44 AM   in response to: user470474 in response to: user470474
Click to report abuse...   Click to reply to this thread Reply
Hi.
I use this statement, i hope that help you

oracle.jbo.domain.Date dbDate;
java.util.Date inputDate;

dbDate= new oracle.jbo.domain.Date(new java.sql.Timestamp(inputDate.getTime());

Bye!
ruben.decramer@...

Posts: 1
Registered: 04/23/08
Re: I can't cast java.util.Date to oracle.jbo.domain.Date
Posted: Jun 2, 2008 2:24 AM   in response to: rengo.Java in response to: rengo.Java
Click to report abuse...   Click to reply to this thread Reply
Hi,

what about the other way around?

Converting a oracle.jbo.domain.Date to java.sql.Date?

Thx in advance,

Ruben
John Stegeman

Posts: 4,477
Registered: 01/16/06
Re: I can't cast java.util.Date to oracle.jbo.domain.Date
Posted: Jun 2, 2008 4:13 AM   in response to: ruben.decramer@... in response to: ruben.decramer@...
Click to report abuse...   Click to reply to this thread Reply
Ruben,

Well, a quick peek of the javadocs shows that oracle.jbo.domain.Date extends oracle.sql.Date, so...

oracle.jbo.domain.Date od = <whatever>;
 
java.sql.Date jd = od.dateValue();

appears to be what you are looking for...

John
Chandresh

Posts: 53
Registered: 09/25/02
Re: I can't cast java.util.Date to oracle.jbo.domain.Date
Posted: Jun 12, 2008 5:43 PM   in response to: John Stegeman in response to: John Stegeman
Click to report abuse...   Click to reply to this thread Reply
Here is what i have seen that works , but does not preserve milliseconds. Does anyone have other solution? Using dateValue() looses hours, mins and seconds.

public oracle.jbo.domain.Date toJboDate(java.util.Date pJavaDate)
{
return new oracle.jbo.domain.Date(new Timestamp(pJavaDate.getTime()));
}

public java.util.Date toJavaDate(oracle.jbo.domain.Date pJboDate)
{
return new Date(pJboDate.timestampValue().getTime());
}

Chandresh
Ram G

Posts: 235
Registered: 02/09/06
Re: I can't cast java.util.Date to oracle.jbo.domain.Date
Posted: Jun 30, 2008 9:52 AM   in response to: Chandresh in response to: Chandresh
Click to report abuse...   Click to reply to this thread Reply
Hi Chandresh,

I have tried your steps but it still storing only the date value and leaving the timestamp. Can you tell me how can I fix this issue? I want to store the user submitted date/time in the database table.

Thanks in advance.
Timo Hahn

Posts: 2,140
Registered: 08/20/04
Re: I can't cast java.util.Date to oracle.jbo.domain.Date
Posted: Jul 1, 2008 12:02 AM   in response to: Ram G in response to: Ram G
Click to report abuse...   Click to reply to this thread Reply
Hi,
how are you looking onto the DB column? if you are using SQLDeveloper you are looking at NLS converted values. You have to change the way SQLDeveloper displays DATE Columns via Tools->preferences->Database->NLSParameters.

Timo
Natalie Koyokina

Posts: 4
Registered: 01/14/09
Re: I can't cast java.util.Date to oracle.jbo.domain.Date
Posted: Jul 9, 2009 7:41 AM   in response to: Chandresh in response to: Chandresh
Click to report abuse...   Click to reply to this thread Reply
Thanks, Chandresh!

First method works, and second - no.

public java.util.Date toJavaDate(oracle.jbo.domain.Date pJboDate)
{
return new Date(pJboDate.timestampValue().getTime());
}

11g Jdev says: cannot assign value...
Legend
Guru Guru : 2500 - 1000000 pts
Expert Expert : 1000 - 2499 pts
Pro Pro : 500 - 999 pts
Journeyman Journeyman : 200 - 499 pts
Newbie Newbie : 0 - 199 pts
Oracle ACE Director
Oracle ACE Member
Oracle Employee ACE
Helpful Answer (5 pts)
Correct Answer (10 pts)

Point your RSS reader here for a feed of the latest messages in all forums