title: Converting date-string to a different format
body: <p>I have a string containing a date in the format <code>YYYY-MM-DD</code>.</p>
  
  <p>How would you suggest I go about converting it to the format <code>DD-MM-YYYY</code> in the best possible way?</p>
  
  <p>This is how I would do it naively:</p>
  
  <pre class="lang-java prettyprint-override"><code>import java.util.*;
  public class test {
      public static void main(String[] args) {
           String date = (String) args[0]; 
           System.out.println(date); //outputs: YYYY-MM-DD
           System.out.println(doConvert(date)); //outputs: DD-MM-YYYY
      }
  
      public static String doConvert(String d) {
           String dateRev = "";
           String[] dateArr = d.split("-");
           for(int i=dateArr.length-1 ; i&gt;=0  ; i--) {
               if(i!=dateArr.length-1)
                  dateRev += "-";
               dateRev += dateArr[i];
           }
      return dateRev;
      }
  }
  </code></pre>
  
  <p>But are there any other, more elegant AND effective way of doing it? Ie. using some built-in feature? I have not been able to find one, while quickly searching the API.</p>
  
  <p>Anyone here know an alternative way?</p>