Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

date inserting

 
sandeep balyan
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello friends
iam having a problem for date
Iam checking in form for a input if input is Yes than insert date if NO than insert null..I tried lots of things but error is coming Not a date format if I insert null...
can any one tell how is this possible..
sandeep
 
kalyan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi sandeep
u have to format the date
u have to capture the date and format in the required format as desired by thru SIMPLE DATE FORMAT and then store it to database i think the following peice of code will help u
java.util.Date MyDate=new java.util.Date(YourDate);
SimpleDateFormat sdf=new SimpleDateFormat("your desired format like dd/MM/yyyy");
String DateToBeStored=sdf.format(MyDate);

and i think if you do not want the date in a particular format u can directly store the SYSdate without formating but i didnt try that.just try that
GOOD LUCK
KALYAN
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic