I am implementing a personnel control system, making use of a fingerprint reader.
I am in the validation stage. My question is: How can I validate between the time obtained and the time the user has established in the database, with a range of acceptance minutes?
Until now this is what I have to do the validation.
public void validarHora(ArrayList<Horario> horas) {
try {
Date now = new Date();
SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");
//obtenemos la hora de chequeo
String s = df.format(now);
//Realizamos la validacion
Date comparar1, comparar2,comparar3;
//hora actual
comparar1 = df.parse(s);
for (Horario hora : horas) {
//hora1
comparar2 = df.parse(hora.getHoraEntrada());
System.err.println(comparar1.compareTo(comparar2));
//hora2
comparar3 = df.parse(hora.getHoraSalida());
System.err.println(comparar1.compareTo(comparar3));
}
} catch (Exception e) {
e.printStackTrace();
}
}
A simple example that I can give.
I go and check at 6:54 am which is at the time I checked in, and on the BD my check-in time is at 7:00 am with a range of acceptance of 10mins which enters the time within the range and vice versa