SimpleDateFormat cast String does not query the database

0

I'm doing a collaborative application for android, so I made a server in PHP, and I send the data to this server.

For a given query I need to pass a date, from a Date Picker, here's the code:

String myFormat = "dd-MM-yy"; //In which you need put here
SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.US);
et_data.setText(sdf.format(myCalendar.getTime()));
String data = sdf.format(myCalendar.getTime()) +"";

The variable date is passed to the server, but on the server it is not interpreting as text.

But if I set the variable date as:

String data = "12-02-2018";

It works normally. The value that arrives on the server is the same, and the type is also String.

Does anyone know what it can be?

    
asked by anonymous 11.06.2018 / 03:46

1 answer

0

Change your format to dd-MM-yyyy because if you put it with 2 y it will get literal value and not numeric.

Ex:

String myFormat = "dd-MM-yyyy";
    
11.06.2018 / 14:10