3
Please, I’m trying to compare hours (like Open Now / Closed Now). But I’m not getting it. To save the current time, I’m using:
object.put("h11", h11.getText().toString());
object.put("h22", h22.getText().toString());
But you’re saved as String; To catch the current time I’m doing so:
SimpleDateFormat hora = new SimpleDateFormat("HH");
Date data = new Date();
Calendar cal = Calendar.getInstance();
cal.setTime(data);
Date data_atual = cal.getTime();
String hora_atual = hora.format(data_atual);
It’s not working out. Could someone give me a suggestion on how to compare hours? Thank you
Checking Time in java
– user28595
Hi Diego. Thank you. See, this "h:mm" I’ll get it from the bank. Saved as string?
– Elaine Breda Schwaner
Could show what format H11.gettext(). toString() and H22.gettext(). toString() ? Thank you!
– Thiago Luiz Domacoski
Hi Thiago, I used a spinner for the user to choose the time, but it already has the timerpicker. But as I thought it would get too big, I used a spinner. H1 is the spinner of hours and min1 is the spinner of minutes.
– Elaine Breda Schwaner
Thiago, to catch the time I used like this: H12.setText(hora1.getSelectedItem(). toString()+":"+min1.getSelectedItem(). toString());
– Elaine Breda Schwaner