import java.util.*; public class TimeCal { long startTime, currentTime; public void TakeStartTime() { GregorianCalendar gc1 = new GregorianCalendar (); gc1.setTime(new Date()); startTime = gc1.getTimeInMillis(); } long getNewTimeDifference() { GregorianCalendar gc2 = new GregorianCalendar(); gc2.setTime(new Date()); currentTime = gc2.getTimeInMillis(); return (currentTime - startTime); } public void RunForSomeTime (long timeinMills) { this.TakeStartTime(); while(this.getNewTimeDifference()