Win a copy of Terraform in Action this week in the Cloud forum!

sean beacham

Greenhorn
+ Follow
since Apr 12, 2011
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
3
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by sean beacham

something like Timer sqltimer; in the main class?

but then when i do an action listener on it what do i do?
10 years ago
I got a problem now i cant use sqltimer.stop(); when i press the disconnect button i get an error on eclipse saying sqltimer cannot be resolved
even though its delcared properly it just cant seem to find variable sqltimer :\

10 years ago

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?



not to worry i think ive confused yourself and myself

i rewrote it like this

10 years ago

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?



ok what i have is 2 jcomboboxes 1 is switch ontime(hourOn,minOn) and the other is switch offtime(hourOff,minOff)
the statement basically says do statement from start time until the end time
10 years ago
Hi everyone,

basically the timer i have coded reads the current time and checks to see whether it is that specific time if yes display on if no display no, it doesnt like the statement i have created.

if (timerhour24 == hourOn < hourOff && timermin == minOn < minOff)

10 years ago
the statement works perfectly fine now thankyou i fixed that yesterday.

im now using swing timers to loop the statement to see if it will change however the gregorian calender only seems to run once that is when you first open the program. Ive tried putting a timer around it and an infinate for loop to see if that works but it doesnt its quite annoying! i kept getting an error. Therefore timerhour24 timermin is a static time that at the time you open the program! and i want to update it in real time.

10 years ago
Theres different suites for different purposes.
10 years ago
i manged to fix the statement problem i was showing my instance variables so i had to remove the int on this statement

still havent fixed the 00 to 09 problem though :\
10 years ago
Personally i use eclipse its a brilliant IDE suite
10 years ago

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.



yes i want to switch something on at a particular time ive modified my code and thats working thankyou although values of 00-09 only produce 1 digit so 00=0 and 09=9 its strange!

1 other thing my statement does nothing!

10 years ago
i changed my mind about getting time in milliseconds im now using gregorian calender which gets the current hour and minute

but right now im getting a silly error, all elements in this statement are ints now i dont get why its being a pain!

The operator && is undefined for the argument type(s) int, boolean

for this specific line:

if (hourOn && minOn == timerhour24 && timermin)

the full code is here:


10 years ago

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...



i dont know what this code does!

i know the first 3 lines get the current hour and minute thats fine.

ive started to write some code so far so good.... a few more tips and i think i should get thre by tomorrow

10 years ago
ok what i mean is

the user has set the timer for continous use until the timer is reprogrammed therefore i want it to check the time constantly and when the time corresponding time arrives Turn On & Off the boiler sets the variable to switch off? do you understand what i mean? So obviously it needs to know when to turn on and off so its comparing the time the user has set to the time on the pc.

10 years ago

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.



will that refresh for every day?

what im trying to do is this.... https://coderanch.com/t/534155/GUI/java/Swing-Calender-ComboBox-timer-questions

i have explained it there im at witts end with it right now :\
10 years ago
what kind of equation surely there must be a statement for get current time in milliseconds for the day? :\
i know :\
1 hour = 3600000
10 years ago