• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

need to send java.util.Date to database with date AND time (so cannot use java.sql.Date)

 
Matt Kohanek
Village Idiot
Ranch Hand
Posts: 484
Java jQuery Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got some help with this yesterday before I was able to do any testing. It was suggested I use java.sql.Timestamp
However, now that I have had time to try that out, I get the following
java.util.Date cannot be cast to java.sql.Timestamp

So that is not going to work. Is there some other type I can use, or is there a way to convert between the two?

Thanks
 
Joanne Neal
Rancher
Posts: 3742
16
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matt Kohanek wrote:I got some help with this yesterday before I was able to do any testing. It was suggested I use java.sql.Timestamp
However, now that I have had time to try that out, I get the following
java.util.Date cannot be cast to java.sql.Timestamp

So that is not going to work. Is there some other type I can use, or is there a way to convert between the two?

Thanks

You can't cast a java.util.Date to a java.sql.Timestamp, but you can create a java.sql.Timestamp using a java.util.Date. Take a look at the javadoc.

 
Matt Kohanek
Village Idiot
Ranch Hand
Posts: 484
Java jQuery Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, yes, of course, the answer was, 'you are a dummy Matt' :p

Thanks
 
Joanne Neal
Rancher
Posts: 3742
16
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matt Kohanek wrote:Ah, yes, of course, the answer was, 'you are a dummy Matt' :p

Thanks

I'm sure you were just demonstrating that your title was well earned.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic