4
I wanted to make a comparison between the date contained in the hora1 object and the system date, as I can do?
import java.text.SimpleDateFormat;
import java.util.Date;
public class MainTarefas {
public static void main(String[] args) {
Date horaMarcada = new Date(1,1,1,1,1);
Date horaAtual = new Date();
System.out.println(horaMarcada.compareTo(horaAtual));
}
}
Although this way of comparing dates is correct in some contexts, it does not answer the question correctly, because the method
compareTo
will compare seconds and even milliseconds and not just the current time.– utluiz