Solved

capturing program time

Posted on 2013-11-20
3
255 Views
Last Modified: 2013-11-29
Hi guys
Is there a way in java to see what time of the day my program runs
For example my java program runs at 12Am, 7am, 6pm monday to saturday
through autosys scheduling tool.
So I need to have something like
If(java program is running at 12am){
// do something
}else if(java program is running at 7am){
//Do something else
}

What would be the best way to do this?
Any ideas would be greatly appreciated.
 Thanks.
0
Comment
Question by:royjayd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 28

Accepted Solution

by:
dpearson earned 500 total points
ID: 39663910
Calendar cal = Calendar.getInstance() ;

int hours = cal.get(Calendar.HOUR_OF_DAY) ;

if (hours > 6 and hours < 8) {
   // It's the 7am run
}

etc.

Doug
0
 

Author Comment

by:royjayd
ID: 39664035
thanks
so just to confirm , if its running at 12 AM, the condition should be
if(hours > 23 && hours < 1), correct ?
0
 
LVL 28

Expert Comment

by:dpearson
ID: 39664295
Yes - that would be the test for midnight (within an hour).

Doug
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question