title: Java String to Integer Conversion
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/5585779/how-to-convert-string-to-int-in-java">How to convert string to int in Java?</a>  </p>
  </blockquote>
  
  
  
  <p>I am trying to figure out how to convert a string that has integers in it to an integer variable.</p>
  
  <p>Code:</p>
  
  <pre><code>import java.util.Scanner;
  
  public class main {
      public static void main(String args[]) {
          Scanner input = new Scanner(System.in);
          System.out.println("Enter date of birth (MM/DD/YYYY):");
          String DOB = input.next();
          String month = DOB.substring(0, 1);
          String day = DOB.substring(3, 4);
          String year = DOB.substring(6, 9);
          int month1 = month;
          int age = 0;
          //age = 2013 - DOB - 1;
          int age2 = 0;
          age2  = age + 1;
          System.out.println("You are " + age + " or " + age2 + " years old");
      }
  }
  </code></pre>
  
  <p>I want to turn <code>String month</code>, <code>String day</code>, and <code>Sting year</code> into integers.</p>