Here is, in my opinion, the most interesting part:
JAVA Code:

//If first time key in date run statement
if(first == 0){
++first;//Track if is the first...