Check if object is on something for certain time

I want to check if an object is on ground/object for certain amount of time.

For example,
if {
object is on ground/something for 3 seconds
“Do something”
}

Is there an easy way to do this in java?

var i : int = 0;

function Start() {
	//function Name, the first run delay in seconds, and a repeat time in second
	InvokeRepeating("Check", 3f, 3f);
}

function Check() {
	Debug.Log(i);
	if (i == 0) myFunction1();
	else if (i == 1) myFunction2();
}

function myFunction1 () {
	i = 1;
}

function myFunction2 () {
	i = 0;
}

function Update() {
	// If You want stop it:
	if (Input.GetKey(KeyCode.A)) {
		//cancel all invokes
		CancelInvoke();
		// or cancel Only the "Check"
		CancelInvoke("Check");
	}
}

IMPORTANT: the times change with Time.timeScale.