Solved

capturing program time

Posted on 2013-11-20
3
252 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
  • 2
3 Comments
 
LVL 26

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 26

Expert Comment

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

Doug
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
mockito example issue 8 73
what is a "java.lang.System Property"   ? 20 67
replace a word with other 1 44
difference of if loops 23 49
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

809 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