aspose file tools
The moose likes Beginning Java and the fly likes Checking for Date Time Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Checking for Date Time" Watch "Checking for Date Time" New topic
Author

Checking for Date Time

Kalyan Anand
Ranch Hand

Joined: Feb 07, 2007
Posts: 194
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.
Red Smith
Ranch Hand

Joined: Aug 05, 2007
Posts: 105
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 )
{

}
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Checking for Date Time
 
Similar Threads
How to read line by line
thread pause after calling a batch file
problem with JTable printing (urgent)
conversion of 1.0000000000005117E-4 to 0.00001
Loop/Array Logic