date comparison – date 2 long – long 2 date – do something after x-min

import java.util.Date;

 * test app for date operations
 * @author mike
public class datecheck {

	 * starts the test app for date 
	 * @param args wont be used...
	public static void main(String[] args) {
		//the exit logic for the while loop
		Boolean exit 		= false;
		//wait time
		Integer BreakTime 	= 1*60000;
		//for storing the start time as long
		Long StartTime 		= 0L;
		//for comparison at runtime
		Long RunTime 		= 0L;
		//earliest ending time
		Long EndTime 		= 0L;

		//get starting time
		StartTime = new Date().getTime();
		//calculate earliest date for end
		EndTime   = StartTime + BreakTime;
		//status message for comparison
		System.out.println("started:  " + new Date() + " (" + StartTime +")");

		//while logic say, repeat loop
		while (!exit){
			//get current time as long
			RunTime = new Date().getTime();
			//if current runtime is past or even earliest date for ending
			if(RunTime >= EndTime){
				//status message and set exit logic
				exit = true;
				System.out.println("reached 1min: " + new Date() + "("+RunTime+" vs "+EndTime+")");

Leave a Reply

Your email address will not be published. Required fields are marked *


Get every new post on this blog delivered to your Inbox.

Join other followers: