Originally Posted by
sehudson
If your "07:34" is a string (lets call it myString),
in Java there is a method called split, that takes in a string and creates a string array whose elements are everything between your delimiter (in your case ':').
So you could do something like
String myString = "07:34";
String[] myStringArray= myString.split(":");
At this point, your myStringArray will have 2 elements in it, and look like this:
myStringArray[0]="07"
myStringArray[1]="34"
Remember, myStringArray is a string array, so your 07 and 34 values are still strings. If you need to manipulate them as integers, you will have to convert the string array to an integer array. If you have a large array, the easiest way would be to walk through a for loop and convert each element in your string array to an integer.
//Declare your new Integer array
int[] myNewIntArray = new int[myStringArray.length];
//Walk through the values in your String array and convert each element to a string/add it to your integer array
for (int i = 0; i < myStringArray.length; i++) {
myNewIntArray[i] = Integer.parseInt(myStringArray[i]);
}
At this point you have an integer array with your new integer values
myNewIntArray[0]=7
myNewIntArray[1]=34
Now, you are free to do any integer operations on either of the 2 array elements.