• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Checking for Date Time

 
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 136
1
Netscape Opera Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 )
{

}
 
reply
    Bookmark Topic Watch Topic
  • New Topic