The issue is that format parsing depends on locale. To be safe you have to explicitly send expected locale when creating instance of SimpleDateFormat
. Otherwise it takes your defult system locale that can be confusing.
This happened in your case. Your program worked well. Then you changed "time format of your computer", that is changed your locale. Then your program stopped working.