aspose file tools
The moose likes Java in General and the fly likes getting today's date Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "getting today Watch "getting today New topic
Author

getting today's date

marys joseph
Greenhorn

Joined: May 14, 2004
Posts: 20
Hi,

I need to get today's date and insert into sql table.

Date d = new Date();
long today = now.getTime();

when I insert this value into sql table hour:min:sec is also inserted. please give me suggestions to get today's date in long value or in timestamp value without hr:min:sec attached to it.

thanks,
clio katz
Ranch Hand

Joined: Apr 30, 2004
Posts: 101
if you're dealing with sql and java 1.4+, it will probably be helpful for you to review the java.sql and javax.sql API's right off

e.g.


if you don't have these packages, you can use milliseconds or Calendar class to construct a SQL DATE in the desired format.

hth!
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
If you want to use TimeStamp

Example code



SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getting today's date
 
Similar Threads
Cannot perform SQL UPDATE null
sql.Date problem
How to get tomorrow's date?
SqlServ er
Insert statement