JUDGER_AND_CLIENT/Common/src/common/TimeTool.java

44 lines
1.1 KiB
Java
Raw Normal View History

2024-01-12 20:48:35 +08:00
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package common;
import java.util.Calendar;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author Administrator
*/
public class TimeTool {
public static void sleep(int time) {
try {
Thread.sleep(time);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
}
public static String getDetailTime() {
Calendar c = Calendar.getInstance();
String hour = String.valueOf(c.get(Calendar.HOUR_OF_DAY));
if (hour.length() < 2) {
hour = "0" + hour;
}
String minute = String.valueOf(c.get(Calendar.MINUTE));
if (minute.length() < 2) {
minute = "0" + minute;
}
String second = String.valueOf(c.get(Calendar.SECOND));
if (second.length() < 2) {
second = "0" + second;
}
String logtime = hour + ":" + minute + ":" + second;
return logtime;
}
}