0

How to do to this instead of putting sqlDate to , imagine 2017-01-08 puts to 01-08-2017 ?

      @Override
    public void onSelectDate(Date date, View view) {


        if(DatesList.contains(date)){
            myDB = CustomApplication.getDatabaseHelper();


            java.sql.Date sqlDate = new java.sql.Date(date.getTime());

            int dateID = myDB.getDateId(sqlDate);
            Log.d(Tag,""+sqlDate);
            String returnedData = getData(dateID);

            Intent i = new Intent(getContext(),TesteInfoDisplay.class);



            startActivity(i);
        }
        else{
            Toast.makeText(getContext(),"Não tem nenhum evento nesse dia.",Toast.LENGTH_LONG).show();
        }

    }
};

The Log of this when I click a date that is on the array is for e.g. 2017-01-01 and I want it to be 01-01-2017

Pedro Gouveia
  • 205
  • 1
  • 7
  • 1
    No, your `java.sql.Date` is not `2017-01-01`, but its `toString()` method happens to return `"2017-01-01"`. You need to use `SimpleDateFormat` to convert from `Date` to `String`. See for example [Convert java.util.Date to String](https://stackoverflow.com/questions/5683728/convert-java-util-date-to-string). – Thomas Fritsch Jul 13 '17 at 16:40
  • Can you be more specific ? – Pedro Gouveia Jul 13 '17 at 16:41
  • I will edit whit the full code – Pedro Gouveia Jul 13 '17 at 16:45

0 Answers0