|
|
![]() |
| Thread Tools | Search this Thread |
#1
| |||
| |||
Java & Oracle: Passing Date
Hello, I parse string into two 2 dates so far nothing too serious. The purpose of these dates is to use a sql query to an Oracle database doing tests to see if a field is in between these 2 dates. Code: prepStat.setDate(INDEX_1, new java.sql.Date(begindate.getTime().getTime())); prepStat.setDate(Index2, new java.sql.Date(endDate.getTime().getTime())); |
#2
| |||
| |||
Re: Java & Oracle: Passing Date
Hello, Especially as I know, such detail is specific to the implementation of the driver / database. In my opinion you have no control over where possible. Oracle is the driver who chooses how he stores a java.util.Date to its tables. To specify the hour / minute / second, it must act on the java.util.Date object that is used with Calendar: Code: Date mydate = ...; Calendar testcal = Calendar.getInstance(); testcal.setTime(mydate); testcal.set(Calendar.HOUR, 0); testcal.set(Calendar.MINUTE, 0); testcal.set(Calendar.SECOND, 0); testcal.set(Calendar.Millisecond, 0); Date newDate = testcal.getTime(); |
#3
| |||
| |||
Re: Java & Oracle: Passing Date
Hi The object is java.sql.Date DATE SQL object that represents a single date without hour / minute / second. For the concept of date + time you must turn to the subject timestamp. This will help you more than sticking to the current code part.
__________________ Grand Theft Auto 4 PC Video Game |
#4
| |||
| |||
Re: Java & Oracle: Passing Date
Hello, I'll try with the TimeStamp object. What I do not understand is that my fields are DATE type in my sql database, but if I look at my data (with sqlDeveloper) I have hours, minutes and seconds are displayed. Does it come from the fact that all my time insertions are done using the Oracle SYSDATE? So if I send via JDBC TimeStamp objects, can-THERE compare objects date of my comics (which have many hours, minutes, seconds)? Thank you |
#5
| |||
| |||
Re: Java & Oracle: Passing Date
Hi, Quote:
Quote:
It is the object is java.sql.Date half naze ... The javadoc says it is quite telling: "To conform with the definition of SQL DATE, the millisecond values wrapped by a java.sql.Date instance must be 'normalized' by setting the hours, minutes, seconds, and milliseconds to zero in the particular time zone with Which the instance is associated." |
#6
| |||
| |||
Re: Java & Oracle: Passing Date
Hello, In standard SQL type DATE contains only a date, type TIME contains only an hour and TIMESTAMP contains both. Objects Date, Time and Timestamp in java.sql represent these different types of weather. Now the level of the DB this can vary because they can implement their own versions and their own types. The conversion is performed during data access. But anyway, you must use the right type depending on what is desired and depending on what we base. |
![]() |
|
Tags: database, java, oracle, programming language |
Thread Tools | Search this Thread |
|
![]() | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Passing by reference in Java | Amy Adams | Software Development | 5 | 06-04-2010 11:17 AM |
Passing optional parameters in java | Miles Runner | Software Development | 5 | 05-03-2010 10:20 AM |
Message Passing in Java | rashmi_ay | Software Development | 5 | 25-02-2010 10:33 PM |
Passing parameter of Oracle procedure in PHP | Halina | Software Development | 3 | 22-04-2009 08:46 PM |
Problem Passing Data Dynamically in Java | Kushan | Software Development | 3 | 26-03-2009 02:26 PM |