You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by SudeepShakya <sh...@live.com> on 2012/04/05 07:27:55 UTC

Inserting String/Date problem .

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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Inserting String/Date problem .

Posted by Martin Grigorov <mg...@apache.org>.
See org.apache.wicket.datetime.markup.html.form.DateTextField#forDatePattern()

On Thu, Apr 5, 2012 at 11:38 AM, SudeepShakya <sh...@live.com> 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: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



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

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Inserting String/Date problem .

Posted by SudeepShakya <sh...@live.com>.
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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Inserting String/Date problem .

Posted by Luca Provenzani <eu...@gmail.com>.
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: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Inserting String/Date problem .

Posted by SudeepShakya <sh...@live.com>.
Hello, is there anyone ??

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Inserting-String-Date-problem-tp4534005p4534020.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org