There is a date string like this: Fri, 22 Apr 2016 15:29:51 +0600

I need to make it like this: 22.04.2016 15:29:51

How can I do this on android? Tell me how to do it, and if you know the link to the article where you can learn how to work with dates and time.

    2 answers 2

    so try

     String date = "Fri, 22 Apr 2016 15:29:51 +0600"; SimpleDateFormat df = new SimpleDateFormat("EEE, dd MMM yyyy hh:mm:ss Z"); SimpleDateFormat output = new SimpleDateFormat("dd.M.yyyy HH:mm:ss"); try { Date res = df.parse(date); String formattedTime = output.format(d); // Это результат } catch (ParseException e1) { } 

    if you need to specify the language, do so

     SimpleDateFormat df = new SimpleDateFormat("EEE, dd MMM yyyy hh:mm:ss zzzz", Locale.ENGLISH); 

    Comment from CJ1 - Here it turns out where the full list of possible formats! Link

     Date today = Calendar.getInstance().getTime(); SimpleDateFormat formatter = new SimpleDateFormat("dd.mm.yyyy hh:mm:ss"); String folderName = formatter.format(today); System.out.println(folderName);