
The final long [] prelongTim={0};
Aaa. SetOnClickListener (new View. An OnClickListener () {
@ Override
Public void onClick (View v) {
If (prelongTim [0]==0) {//the first click, initialized to the time of the click
PrelongTim [0]=(new Date ()). The getTime ();
} else {
Long curTime=(new Date ()). The getTime ();//click here time
Aaa. SetText (" end ");
System. The out. Println (" click two intervals of time: "+ (curTime - prelongTim [0]));//calculation in local and the last time
If (curTime - prelongTim [0] & gt; 5 * 1000) {
//5 seconds allows click, can according to need to modify the time interval between
PrelongTim [0]=curTime;//the click event to the last time
}
}
}
});

CodePudding user response:
Can use SimpleDateFormat tools to formatting time, baidu, a lot of, learn to check before they askCodePudding user response:
Long currentTimeMillis=System. CurrentTimeMillis ();The Date the Date=new Date (currentTimeMillis);
String STR="yyy - MM - dd HH: MM: ss".
SimpleDateFormat SDF=new SimpleDateFormat (STR);
System. The out. Println (SDF) format (date));
http://c.biancheng.net/view/878.html