`

Java获取当前系统时间

阅读更多
//导入
import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;     
  

Date dt=new Date();//如果不需要格式,可直接用dt,dt就是当前系统时间
DateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");//设置显示格式
String nowTime="";
nowTime= df.format(dt);//用DateFormat的format()方法在dt中获取并以yyyy/MM/dd HH:mm:ss格式显示
System.out.println("当前时间<毫秒>:"System.currentTimeMillis());//输出毫秒时间
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics