if (temp1.substring(0, 7).
I see numerous line where you are calling substring with hardcoded values. What happens when a String with less than 7 characters is used?