0
I have a variable int that is taking the current time of android and comparing with more dua variables int of my database in the parse that contains the opening and closing time of a company, in companies of commercial schedule works, but when a company opens day and closes at dawn for example, I already have a problem, because if a company closes at 1:00 and it 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 for example I use some code that makes recognize, 00 < 01 < 02 < 03, and so on, just as the hours are recognized in a normal watch.
What value
parseUser4.get("horaAbertura").toString()
orparseUser5.get("horaFechamento").toString()
?– Isac
The "opening hours" contain the opening hours of the company, for example 0700, as well as the "opening hours" contains the closing hours, for example 1730.
– Alekssander Augusto