You can try using a HashMap to store the map from the date string to integer offset. Possibly it will be faster, but the real advantage is simplifying your code.