Inserting String/Date problem .

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Inserting String/Date problem .

SudeepShakya
I have two textboxes which take dates using datepicker(I have set Date.class in the Textbox also) and a dropdown choice which takes 'telecom' and I have getters and setters for all of them. I have set all of them as String. And the query  and code for doing the operation for selecting the data is below :

String query = "SELECT * FROM tbl_vote INNER JOIN tbl_contestant WHERE ( ( (tbl_vote.tokenID = tbl_contestant.tokenID) AND tbl_vote.telecom = ?)  AND (date_time >= ? AND date_time <= ?))";

 PreparedStatement statement = this.db.prepareStatement(query);
          statement.setString(1, aVote.getTelecom());
           statement.setString(2,aVote.getDate1());
              statement.setString(3, aVote.getDate2());  

The datepicker sets the date in format 4/5/12 (dd/mm/yy) but I know that mySql use the format yyyy-mm-dd. So when i enter the dates and the other field, the data is not retrieved.
So how to set date to the database ? I have set Date field as 'datetime' in database.
Is there some wrong logic in my code/query ?
Reply | Threaded
Open this post in threaded view
|

Re: Inserting String/Date problem .

SudeepShakya
Hello, is there anyone ??
Reply | Threaded
Open this post in threaded view
|

Re: Inserting String/Date problem .

Luca Provenzani
In reply to this post by SudeepShakya
Hi,
this is not a wicket question, but a java question.
However: why do you use String for a Date information?
Statement has setDate method and wicket has DateField and DateTextField.

Bye
Luca



Il 05/04/2012 07:27, SudeepShakya ha scritto:

> I have two textboxes which take dates using datepicker(I have set Date.class
> in the Textbox also) and a dropdown choice which takes 'telecom' and I have
> getters and setters for all of them. I have set all of them as String. And
> the query  and code for doing the operation for selecting the data is below
> :
>
> String query = "SELECT * FROM tbl_vote INNER JOIN tbl_contestant WHERE ( (
> (tbl_vote.tokenID = tbl_contestant.tokenID) AND tbl_vote.telecom = ?)  AND
> (date_time>= ? AND date_time<= ?))";
>
>   PreparedStatement statement = this.db.prepareStatement(query);
>            statement.setString(1, aVote.getTelecom());
>             statement.setString(2,aVote.getDate1());
>                statement.setString(3, aVote.getDate2());
>
> The datepicker sets the date in format 4/5/12 (dd/mm/yy) but I know that
> mySql use the format yyyy-mm-dd. So when i enter the dates and the other
> field, the data is not retrieved.
> So how to set date to the database ? I have set Date field as 'datetime' in
> database.
> Is there some wrong logic in my code/query ?
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Inserting-String-Date-problem-tp4534005p4534005.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Inserting String/Date problem .

SudeepShakya
I have solved the problem but I want to ask  question about DatePicker.
DatePicker sets date in the format mm/dd/yy or may be dd/mm/yy but mySql's format is yyyy-mm-dd.
How can i change the format how the DAtePicker sets the date ?
Reply | Threaded
Open this post in threaded view
|

Re: Inserting String/Date problem .

Martin Grigorov-4
See org.apache.wicket.datetime.markup.html.form.DateTextField#forDatePattern()

On Thu, Apr 5, 2012 at 11:38 AM, SudeepShakya <[hidden email]> wrote:

> I have solved the problem but I want to ask  question about DatePicker.
> DatePicker sets date in the format mm/dd/yy or may be dd/mm/yy but mySql's
> format is yyyy-mm-dd.
> How can i change the format how the DAtePicker sets the date ?
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Inserting-String-Date-problem-tp4534005p4534359.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>



--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]