wood burning stoves 2.0*
The moose likes Java in General and the fly likes sql date and time - how I construct one date out of them? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "sql date and time - how I construct one date out of them?" Watch "sql date and time - how I construct one date out of them?" New topic
Author

sql date and time - how I construct one date out of them?

John Landon
Ranch Hand

Joined: Sep 25, 2008
Posts: 227
Hi,
I have sql date and sql time. I want to construct one Date object with the date that I have and time that I have.
How?

Thanks.
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2840
    
  11

Do you mean you have a java.sql.Date and java.sql.Time? If I remember right, they are just java.util.Date subclasses that zero out the time and date parts respectively. I think it should be enough to getTime() from both and combine them with a bitwise and. Like:



I'll leave it to you to verify that works.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19653
    
  18

If that doesn't work you can use a couple of Calendar objects:


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2840
    
  11

By bitwise and I of course meant bitwise or. Bitwise and would work too, but only if your time and date is January 1, 1970 at midnight GMT.
 
Don't get me started about those stupid light bulbs.
 
subject: sql date and time - how I construct one date out of them?
 
Similar Threads
how to retreive date
Date and Calender class with applet
How I can compare date value and Retrieve Date?
Convert sql date to util date
Date method