Code example for Time

Methods: after, setToNow

0
    /** 
     * Return whether it's ok to fetch new data (if it's been 1 hour since the last fetch) 
     * @return 
     */ 
    public boolean okToFetchLeague() { 
    	Time now = new Time();
    	now.setToNow();
    	if(lastLeagueFetch == null) {
    		lastLeagueFetch = new Time();
    		lastLeagueFetch.setToNow();
    		System.out.println("It's ok to fetch league!");
    		return true; 
    	} 
    	 
    	if(now.hour - lastLeagueFetch.hour >= 1 && now.after(lastLeagueFetch)) {
    		System.out.println("It's ok to fetch league!");
    		if(lastLeagueFetch == null)
    			lastLeagueFetch = new Time();
    		lastLeagueFetch.setToNow();
    		return true; 
    	}