This week's book giveaway is in the General Computing forum.
We're giving away four copies of Learning Regular Expressions and have Ben Forta on-line!
See this thread for details.
Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

On java.sql.Timestamp and java.sql.Date  RSS feed

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
Can anybody help me to convert to convert 12-JAN-2000 to timestamp.
Also:
If I declare the date variable as java.sql.Date with the above input I am not able to get the timestamp format
I have declare date as Datetime in SQL SERVER.
In java should I declare as java.sql.Date OR java.sql.Timestamp?
In either way pl. help me with the code.
thanx a lot.
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use getTime() method of java.sql.Date to instantiate java.sql.Timestamp(long time).
 
Bhuvana Bala
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by dip ch:
Use getTime() method of java.sql.Date to instantiate java.sql.Timestamp(long time).



Can u please be clear. I tried with it .But I dont get it.
Now I need to convert calendar. to Timestamp.
Calendar c1= Calendar.getInstance();
c1.set(2000,12,32);
java.util.Date d= c1.getDate();
java.sql.Date dt=new java.sql.Date(d.getTime);
Now dt is the sql Date. I need java.sql.Timestamp format.Pl. help
pl. see
Thanx

[This message has been edited by Bhuvana Bala (edited July 24, 2001).]
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you need to read java api documentation. java school of this site is also a good place.
corrected code:
java.util.Calendar c1= java.util.Calendar.getInstance();
c1.set(2000,12,32);
java.util.Date d= c1.getTime();
java.sql.Date dt=new java.sql.Date(d.getTime());
(Sorry for late reply - naming convention of the site created problem!!)
bye
DC
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!