Forums Register Login

Checking for Date Time

+Pie Number of slices to send: Send
I am writing a batch program. The batch program has a check as below how do I write it, any suggestions ?

Check the current system time falls between Saturday 1.00 AM and Sunday 1.00 PM.
+Pie Number of slices to send: Send
 

Originally posted by Santhosh Jali:
I am writing a batch program. The batch program has a check as below how do I write it, any suggestions ?

Check the current system time falls between Saturday 1.00 AM and Sunday 1.00 PM.



Create a Calendar() object. Then use it's get() method to see if (DAY_OF_WEEK is Saturday and HOUR_OF_DAY >= 1) or (DAY_OF_WEEK is SUNDAY and HOUR_OF_DAY < 13).

Calendar is a class that isn't constructed with new. You have to call it's getInstance() method.

Calendar now = Calendar.getInstance();

To get values you have to use Calendar defined constants

int theHourOfDay = now.get(Calendar.HOUR_OF_DAY)
if ( now.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY )
{

}
Destroy anything that stands in your way. Except this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1087 times.
Similar Threads
conversion of 1.0000000000005117E-4 to 0.00001
thread pause after calling a batch file
problem with JTable printing (urgent)
Loop/Array Logic
How to read line by line
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 14:10:40.