rikojir
rikojir

Reputation: 115

Sending java.util.date / java.sql.date using BasicNameValuePairs in Android

I am currently working on an app that inserts some data into a database.

I send this data using BasicNameValuePairs which I construct like this:

nameValuePairs.add(new BasicNameValuePair("date", dateList.get(i).toString()));

where dateList is an ArrayList. Using the toString()-method works fine, but then the date is inserted as a String in the database, so that you can't order the dates later which is a problem for me.

I wanted to use the original date datatype or even convert it to java.sql.date and pass it into a BasicNameValuePair, but the constructor of BasicNameValuePair only allows strings, no other datatypes.

Has anyone an idea how I can solve this? I get the data in PHP and insert it in my database, so I can

a) Try to convert my string in PHP to a SQL-Date or

b) Try to convert it inside my JAVA code and send a java.sql.date or anything like that.

Anyone a suggestion what to do and how to do it? :-)

Upvotes: 1

Views: 260

Answers (0)

Related Questions