.... if(System.currentTimeMillis() + (convert 5 min to milliseconds) > timestamp ){ //generate new lotto number and update timestamp .. Check the client input with generated number as well ..