The question is probably stupid and will seem frivolous to many, but I have to ask it, because he did not find a solution.

It is necessary to display the date in TextView as follows: Number.Mesa.Year (example: 04/27/2017). An important caveat: should work on API 19 and above.

    2 answers 2

    You can, for example, do this in the following way:

    String date = new SimpleDateFormat("dd.MM.yyyy").format(new Date()); 
    • It also works, but with API 25 and higher, and with API 19 and higher. - Evgeny
    • 3
      @Evgeny, you are wrong. The class is available with API 1. Follow the link: developer.android.com/reference/java/text/SimpleDateFormat.html and in the upper right corner there is the version of the API with which it is available - UjinUkr
    • The easiest and most convenient option. Thank! - Evgeny
    • @Evgeny, if you are satisfied with the answer, mark it as accepted by clicking on the check mark. - Kirill Malyshev

    Everything is simple

     DateFormat dateFormat = SimpleDateFormat.getDateInstance(SimpleDateFormat.SHORT); String text = dateFormat.format(dateValue); 

    Date formatting will be in accordance with the user's locale settings.

    • But this will only work on API 24 and higher. And I need, starting from API 19 and above - Evgeny
    • one
      You need to import java.text.SimpleDateFormat and java.text.DateFormat. stackoverflow.com/questions/39055963/… - Cyril Malyshev
    • And what will it give? - Evgeny
    • 2
      These classes are added with API 1 - Cyril Malyshev
    • one
      @Evgeny if there is more than one class with the same name, but from different packages, then AS does not add any one at will, but offers to choose from the existing ones. You need to choose from the java.text package. In general, the answer is correct and no one else will write to you, that you cannot cope with auto import, as if your problem. Disable it altogether and import manually then. - pavlofff