title: How to get formatted Date from string android?
body: <p>I'v searched for many solutions on SO and didn't find one which worked for me (because of deprecation of some methods etc.). I have a simple problem which can be surely solved within 1 min, but i couldn't find or figure out any solution. I would like to get from string</p>
  
  <pre><code>Wed Sep 23 04:45:21 EDT 2015
  </code></pre>
  
  <p>another string which should look like</p>
  
  <pre><code>23.09.2015. 04:45:21
  </code></pre>
  
  <p>I know that first i need to change my string into date and then format that date into string but after 4 hours i kinda give up. </p>
  
  <p>So far i tried many things and nothing works. Code example follows which dont work</p>
  
  <pre><code>String dateobj = "Wed Sep 23 04:45:21 EDT 2015";
  SimpleDateFormat format = new SimpleDateFormat("dd-MM-yyyy'T'HH:mm:ss'Z'");
  try {
          Date date1 = format.parse(dateobj);
      } catch (ParseException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  </code></pre>
  
  <p>Any solution?</p>
  
  <p>Thanks in advance</p>
  
  <p>EDIT: </p>
  
  <pre><code>try{
  String dateobj = "Wed Sep 23 04:45:21 EDT 2015";
  SimpleDateFormat format = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy"); //
  SimpleDateFormat format1 = new SimpleDateFormat("dd.MM.yyyy. HH:mm:ss"); // for display
  
  Date date = format.parse(dateobj); // parse it to date
  System.out.print(format1.format(date)); // display the date to format you like
   // the print result is : 23.09.2015. 08:45:21
  } catch (Exception e){
  System.out.print("error"); }
  </code></pre>
  
  <p>Code below works only for <code>Wed Sep 23 04:45:21 EDT 2015</code>.</p>
  
  <p>And how to modify this code if i don't have <code>Wed Sep 23 04:45:21 EDT 2015</code>? My date on phone looks like <code>Wed Sep 23 04:45:21 CEST 2015</code>. How to modify code? </p>