| Author |
Hard time with java.sql.date
|
Giselle Dazzi
Ranch Hand
Joined: Apr 20, 2003
Posts: 168
|
|
Beginner's question: I want to create a Date object using the constructor:
Date(long date) Constructs a Date object using the given milliseconds time value.
but Im having a very hard time figuring out how to find out the current date in miliseconds... I tried creating a Calendar object, using But still there is no method that gives me a value in miliseconds... thx in advance,
|
Giselle Dazzi<br />SCJP 1.4
|
 |
Benny Tang
Greenhorn
Joined: Aug 03, 2003
Posts: 26
|
|
Hi, After the instantiation of the Calendar instance, you can obtain a Date instance by invoking the method getTime() in the class Calendar. Hopes this can help you. Benny Tang
|
 |
deepak yadav
Greenhorn
Joined: Oct 04, 2001
Posts: 17
|
|
I am replying on the basis of the subject, the contents of the post didn't revealed that the actual problem is with java.sql.Date java.sql.Date doesn't have a time component, so there is not much point in making an instance of that using a time precision of miliseconds -deepak
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24054
|
|
Gizelle -- Benny's statement is correct, but if all you want is the current time in milliseconds, you can get it using the static method System.currentTimeMillis(). Deepak -- Have a look at the constructor java.sql.Date(long).
|
[Jess in Action][AskingGoodQuestions]
|
 |
deepak yadav
Greenhorn
Joined: Oct 04, 2001
Posts: 17
|
|
Hi Hill, java.sql.Date does have the time component but it is better not to use it because it has been deprecated long ago. Also i had problems using java.sql.Date in CMP (WLS 8.1). The time component wasn't appearing in the database(Oracle 8i), but when i used java.util.Date or java.sql.Timestamp it worked fine. ------------------------------------------- This is from 1.3.1 javadocs public int getHours() Deprecated. This method is deprecated and should not be used because SQL Date values do not have a time component. ------------------------------------------- -deepak
|
 |
Jamie Robertson
Ranch Hand
Joined: Jul 09, 2001
Posts: 1879
|
|
Originally posted by Giselle Dazzi: Beginner's question: I want to create a Date object using the constructor:
double check to make sure that the getTime() method preserves the "brasilia" time zone or if it reverts back to the default timezone of the computer. Jamie
|
 |
Giselle Dazzi
Ranch Hand
Joined: Apr 20, 2003
Posts: 168
|
|
Thanks for the help everybody ! It has been crazy with this project I have to finish, I ended up not thanking you sooner.
|
 |
 |
|
|
subject: Hard time with java.sql.date
|
|
|