java - Restrict button from being clicked based on the time of the day ANDROID -


I need to restrict a button by clicking on the time of day in my Android app. For example, I do not need to order the app after 9 o'clock, so I want to disable the button after that time. I have seen it in and seen "time now = new time ();" After a method that says that there is an input of time. I tried 900, 9: 00 and 9 .00, no luck, do anyone know how this can be done?

My experience with the timing of the link is a little limited, so I'm not sure there are better ways to exist, But how do I do it

  DateTime now = DateTime.now (); If (now.Gethofed ()> = 21) {System.out.println ("Disable it."); } Else {System.out.println ("Enable it."); }   

This can also be done with the Java API

  calendar calendar = calendar.forest (); If (calendar.get (calendar.HOUR_OF_DAY) & gt; = 21) {System.out.println ("it is dysfunctional."); } Else {System.out.println ("Enable it."); }   

But if you need to work with dates / etc. You can start using the add-on.

This will be disabled from 0 - 21 , 21 - 23

will be disabled from this code inside OnResume

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -