1

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? :-)

rikojir
  • 115
  • 2
  • 13
  • Is this in the android database that you're saving this? Because android uses SQLite which saves dates as a string so it wouldn't matter. But why wouldn't you be able to order them? They'd be stored something along the lines of "year-month-day hour:minute:second" which, as actual values, sorts just fine chronologically. – Joseph Roque May 26 '15 at 18:18

0 Answers0