1. 获取当前时间
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateTimeTest {
public static void main(String[] args) {
DateTimeTest.getCurrentTime();
}
//12-17 14:02:34
public static String getCurrentTime(){
Date date = new Date();
String strTime;
DateFormat dateFormat = new SimpleDateFormat("MM-dd HH:mm:ss");
strTime = dateFormat.format(date);
//System.out.println(strTime);
return strTime;
}
}
待续