1
I wanted to know how to see if the current system time is within a previously defined radius
I currently have this code, but it always returns "Closed at the moment"
Calendar calendar = Calendar.getInstance();
final Date horaCheck = calendar.getTime();
try{
String horaAbre = getmHoraAbre();
Date hourAbre = new SimpleDateFormat("HH:mm").parse(horaAbre);
String horaFecha = getmHoraFecha();
Date hourFecha = new SimpleDateFormat("HH:mm").parse(horaFecha);
if (horaCheck.after(hourAbre) && horaCheck.before(hourFecha)) {
disponivelInfo.setText("Aberto no momento");
} else {
disponivelInfo.setText("Fechado no momento");
}
} catch (Exception e){
e.printStackTrace();
}
I’m using Firebase, sorry I forgot to tell you
– Léo Santos
I had experiences with date and time formatted in firebase and were not very good, mainly for queries. I recommend working with the hour in milliseconds.
– Grupo CDS Informática
Your opinion is of great help, thanks for the tip
– Léo Santos