| Author |
Just realise something interesting about Date in Java and SQL
|
Farhad Rahmati
Ranch Hand
Joined: Dec 16, 2010
Posts: 96
|
|
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
Joined: Nov 24, 2005
Posts: 14685
|
|
|
The SimpleDateFormat for month is MM not mm.
|
[My Blog]
All roads lead to JavaRanch
|
 |
Farhad Rahmati
Ranch Hand
Joined: Dec 16, 2010
Posts: 96
|
|
Thank you very much Christophe
it is sloved, I am new in Java and it's my first project
Thanks again
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14685
|
|
Farhad Rahmati wrote:I am new in Java and it's my first project
Good luck
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14685
|
|
Farhad Rahmati, Your post was moved to a new topic. I moved your post to the Swing forum
|
 |
 |
|
|
subject: Just realise something interesting about Date in Java and SQL
|
|
|