Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Just realise something interesting about Date in Java and SQL

 
Farhad Rahmati
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Guys

I was working on my project and and trying to find a way to store a date from JTextField to JavaDB database. I found a way to as the following code



so, it's okay and working gets String, converts to java.util.date and converts the Java date to sql.date and sends to database

but the interesting thing is it sends the first month which is Jan.
any date you enter, it just converts to Jan, however the year and the day is Okay as you entered. it changes only the month to Jan

any idea how to solve it? if not then could you please provide any alternative to save an entered String in JTextField as a date in JavaDB database.

your help is appriciated
Thanks

 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The SimpleDateFormat for month is MM not mm.
 
Farhad Rahmati
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much Christophe

it is sloved, I am new in Java and it's my first project

Thanks again
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Farhad Rahmati wrote:I am new in Java and it's my first project

Good luck
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Farhad Rahmati,
Your post was moved to a new topic.
I moved your post to the Swing forum
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic