So I tried to make a timer that will stop at specific time i put in the if statement, though it didn't work. Is there a way I can do this that will work?
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Calendar;
public class time {
public static void main(String args[]) {
do {
Date date = Calendar.getInstance().getTime();
DateFormat dateFormat = new SimpleDateFormat("dd hh:mm:ss");
String strDate = dateFormat.format(date);
System.out.println(strDate);
if (strDate == "06 03:22:30") {
System.out.println("timer done");
}
} while (true);
}
}
Aucun commentaire:
Enregistrer un commentaire