Paul Clapham wrote:That isn't at all helpful. You posted an if-statement, but now you're saying it says "do from start time to end time"? That doesn't make any sense at all, because you can't do that with an if-statement.
Not to mention that your if-statement refers to variables named timerhour24 and timermin, but your explanation doesn't refer to those variables in any way.
Let's try again. Your if-statement was meant to compare two values. Or maybe four values, I don't know. Can you explain what those values are, what they mean, and how you meant to compare them?
Paul Clapham wrote:
sean beacham wrote:it also doesnt like this statement
if (timerhour24 == hourOn < hourOff && timermin == minOn < minOff)
Well, that's because it isn't valid Java syntax (which you already knew because you got a compiler error). However I don't have any suggestions about how to fix it, because I can't tell what it was supposed to mean. Could you explain it in words?
Campbell Ritchie wrote:You can't use the && operator like that. I am not quite sure what that means, but do you mean you want a particular turn-on time? You would probably want if (min == minOn && hour == HourOn) . . .
By the way: there is a better way to fill your arrays, which I edited to shorten the lines.I am not sure why you need those String arrays at all. You can print out the numbers with the %d tag and not use Strings.
Abhilash Etikala wrote:Use GregorianCalendar() to get the current time and compare with the selected time...
Here is the sample code. to get time..
Since,String arrays contains the integer values you can use the below code to initialize the combo box..
hope this helps u...
Jesper de Jong wrote:Another way:
Get a Calendar object, set it to today, and set the hours, minutes, seconds and milliseconds to 0. Call getTimeInMillis() on it.
Call System.currentTimeMillis() to get the current time in milliseconds. Subtract the value that you got above from it, and you have the number of milliseconds since midnight.