• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java.util.Date and java.sql.Date problem

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi

i use mysql database.User's date of birth is caught by java.util.Date in backing bean.while insert into database,mysql cannot accept.Cannot insert into table.Query not ok.if use java.sql.Date,also same result.
I have known sql.Date into mm/dd/yyyy.java.util.Date is little long.
if i use now() function in mysql,i can display like mm/dd/yyyy while i retrieve the date.
that is why?
Please help me.
 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howzit Tun,

This is not a JSF question. So I assume someone is going to move this post. But I'll see if I can help anyway.

You want to convert from java.util.Date to a java.sql.Date. Is that correct?

have you try instantiating a java.sql.Date with the constructor that accepts a long as a parameter, and you get that long from java.util.Date.getTime()?
java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
 
tun zaw
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for your answer.
thank you very much.
tunzaw
reply
    Bookmark Topic Watch Topic
  • New Topic