Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

capturing program time

Posted on 2013-11-20
3
Medium Priority
?
258 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
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 third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

618 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