How to take number values from a String, and convert them to int using a for loop?

Posted: - Source : stackoverflow

I want to create a loop that will take the String values and convert them into int values. Here is an example String 2012.12.31 What I want is to kill loop once it get's to the "." We will assume that all strings will contain only 2 "." in them. Here is what I started with, and I am stuck. Can some one guide me to what can be used? I am a java learner, so I don't even know all the system commands that can be used in this case. Here is how i wanted to go through with it.

DateSettings (String A){
    int YYYY, MM, DD;

    for (int i=0; i<A.indexOf('.'); i++);{
        YYYY = A[i];