title: Java How to read date dynamically
body: <p>I have a string with six numbers: <code>650310</code>. It represents <code>1965 march 10</code> in <code>YYMMDD</code> format.</p>
  
  <p>Is there any method to recognize this format to <code>10 march 1965</code>?
  Currently this is my method of doing which isn't very effective.</p>
  
  <pre><code>public class Example {
  
      public static void main(String args[]) {
          //date in YYMMDD
  
          //String x = "650310";
          String x = "161020";
          System.out.print(x.substring(4, 6)+" ");
  
          if (Integer.parseInt(x.substring(2, 4)) == 10) {
              System.out.print("October"+" ");
          }
          else  if (Integer.parseInt(x.substring(2, 4)) == 03) {
              System.out.print("March"+" ");
          }
          if (Integer.parseInt(x.substring(0, 2)) &gt; 50) {
              String yr = "19" + x.substring(0, 2);
              System.out.println(yr);
          } else if (Integer.parseInt(x.substring(0, 2)) &lt; 50) {
              String yr = "20" + x.substring(0, 2);
              System.out.println(yr);
          }
      }
  }
  
  output : 20 October 2016
  </code></pre>