格式化时间(SimpleDateFormat)
import java.text.SimpleDateFormat; import java.util.Date; public class Main{ public static void main(String[] args){ Date date = new Date(); String strDate = "yyyy-MM-dd HH:mm:ss"; SimpleDateFormat sdf = new SimpleDateFormat(strDate); String strDT = sdf.format(date) ; System.out.println(strDT); } }