Hello, I have an Android application that takes the date from a DatePicker but I am not able to convert it to the type accepted by MYSQL in the Date case how could I do this?
Hello, I have an Android application that takes the date from a DatePicker but I am not able to convert it to the type accepted by MYSQL in the Date case how could I do this?
The dates in MySQL have the format 'YYYY-MM-DD' and support a range of '1000-01-01' through '9999-12-31'. Make sure the date you are reporting is in this format and is valid. If you need to convert, use the SimpleDateFormat . Ex:
SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd");
String dateFormat = dateformat.format(new Date(datePicker.getYear(), datePicker.getMonth(), datePicker.getDayOfMonth()));
You can change the global variables of your database to the format of your application, but I indicate some formatting of the application to the database, to maintain the default, but if you want to change the database, the variables are the would look like this:
SET @@ date_format = '% d /% m /% Y'; SET @@ datetime_format = '% d /% m /% Y% H:% i:% s';