how to find time of a button pressed

I have force and need to set it with the time of button pressing and holding and after releasing the button , time change to a number and get in my force value but don’t know how to do it?
how can I find and access the time of button pressing?
(Please answer with java)

Just use Time.time

var timePressed:float;
function OnGUI() {
   if (GUI.Button(new Rect(55, 170, 120, 20), "Press")) timePressed = Time.time;

var button_press_time : float = 0.0; // button_press_time variable to store our time

function OnGUI()
	if (GUI.Button(Rect(0,0,200,200),"Time")) //Check when button is pressed
		button_press_time = Time.time; //Set button_press_time  to current time
		Debug.Log(button_press_time); // Print button_press_time to console

Same goes for standard Input methotds.