When you have strings like "10-07-2015" and "01-08-2017" in your database and use ORDER BY the printed result will be in the sequence of "01-08-2017" , "10-07-2015" .
Same thing happens when you put the string dates into a Treemap, because both Treemap and ORDER BY identify the input as numbers, not as dates.
When you use a different date format, like "yyyy-MM-dd", here the print output is in the correct sequence, "2015-07-10" , 2017-08-01". But it is in the wrong date format.
One workaround solution would be to convert dates into longs before adding them to the database :
Date date_1 = Mon Jul 10 16:06:22 BRT 2015;
Date date_2 = Fri Aug 01 14:04:23 BRT 2017;
Long long_Date_1 = date_1.getTime(); // (prints something like 1502133102260)
Long long_Date_2 = date_2.getTime(); // (prints something like 1233335544343)
When you put these longs into the database, you can retrieve them sorted from the database and easily convert them into date string with the desired format:
Date date_1 = new Date ( long_Date_1 );
Date date_2 = new Date ( long_Date_2 );
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
formatter.format(date_1)); // prints "10-07-2015"
formatter.format(date_2)); // prints "01-08-2017"