I have an int variable that is picking up the current android time and comparing with more dua int variables from my database in the parse that contains the opening and closing times of a company in business hours trading works, but when a company opens day and day dawn for example, I already have problem, because if a company closes at 1:00 and is 00:00, the application recognizes that it is closed.
SimpleDateFormat sdf = new SimpleDateFormat("HHmm", Locale.getDefault());
Date hora = Calendar.getInstance().getTime();
int horaAtual = Integer.parseInt((sdf.format(hora)));
int horarioAberto = Integer.parseInt(parseUser4.get("horaAbertura").toString());
int horarioFechado = Integer.parseInt(parseUser5.get("horaFechamento").toString());
if (horaAtual < horarioAberto) {
horario.setText("FECHADO");
horario.setTextColor(getContext().getColor(R.color.vermelho));
} else if (horaAtual > horarioFechado) {
horario.setText("FECHADO");
horario.setTextColor(getContext().getColor(R.color.vermelho));
} else if (horaAtual >= horarioAberto) {
horario.setText("ABERTO");
horario.setTextColor(getContext().getColor(R.color.verde_limao));
} else if (horaAtual <= horarioFechado) {
horario.setText("ABERTO");
horario.setTextColor(getContext().getColor(R.color.verde_limao));
}
I wanted to know if you have, for example, I use some code to recognize, 00 < 01 < 02 < 03, and so on, just as hours are recognized on a normal clock.