I have written code that solves a boggle board and now I want to convert it into my own game. I have everything I need except I cannot figure out how to set a time limit so the person can only enter words in for a 2 minutes. This is what I have so far, but it doesn't do what i want it to do, which is to stop after 2 mins.
long startTime = System.nanoTime();
long endTime1=0;
long maxDurationInMilliseconds = 2 * 60 * 1000;
while (2 * 60 * 1000> endTime1-startTime) {
System.out.println(System.currentTimeMillis());
System.out.print("Guess a word on the board! ");
if(test.CheckGame(scan.next())==true){
System.out.print("Good job! ");
}
else
System.out.print("Guess again! ");
endTime1 = System.nanoTime();
}