This topic has
7
replies
on
1
page.
Good morning to everyone !,
Could anybody help me?
I need to know how to get the current System time... ??
I need the source code to get it as a Timestamp. I think this type belongs to the class java.sql.Timestamp
Which is the easiest way to do this?
I need to get it, to insert it in a database datetime field afterwards.
Thanks in advance for your time.
zadok
Posts:4,003
Registered: 8/7/06
Why not just use getDate() in SQL?
Anyway in Java just use
System.currentTimeMillis()
and convert it to a TimeStamp
Setter
Posts:15
Registered: 3/27/07
Try:
Timestamp time = new Timestamp(System.currentTimeMillis());
Also:
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/System.html#currentTimeMillis()
and
http://java.sun.com/j2se/1.5.0/docs/api/java/sql/Timestamp.html
hi
Date d1=new Date();
d1 will contains current system date and time..
is that enough
Hello again, thanks for all the kind replies...
I think I will go for this Option:
Timestamp time = new Timestamp(System.currentTimeMillis());
Seems very coherent to me. Do you know If I can insert it inside a datetime field of a DB Table?
Thank you guys, you always exceed my expectations
Sincerely, Jose
which database are you using
I am using
SYBASE
thanks...
DrClap
Posts:38,727
Registered: 4/30/99
Seems very coherent to me. Do you know If I can
insert it inside a datetime field of a DB Table?
Yes, it's easy to do that with a PreparedStatement.
This topic has
7
replies
on
1
page.
Back to Forum
Read the Developer Forums Code of Conduct
Email this Topic
Edit this Topic
Site Upgrade
Forums 7.1.8 was deployed Oct 26th. The release consists of minor fixes & a few enhancements.
Forums Statistics
Users Online : 63 Guests : 118
About Sun forums
Sun Forums is a large collection of user generated
discussions. It is here to help you ask questions, find answers, and
participate in discussions.
Check out our guide on Getting
started with Sun Forums for a full walkthrough of how to best
leverage the benefits of this community.