java获取当前时间

来源:互联网 发布:linux如何gzip压缩 编辑:程序博客网 时间:2024/06/10 19:21
[1]

SimpleDateFormat tempDate = new SimpleDateFormat("yyyy-MM-dd" + " "+ "hh:mm:ss");
String datetime = tempDate.format(new java.util.Date());
[2]

Calendar now=Calendar.getInstance();
Stringtime=now.get(Calendar.YEAR)+"-"+(now.get(Calendar.MONTH)+1)+"-"+now.get(Calendar.DAY_OF_MONTH)+""+now.get(Calendar.HOUR_OF_DAY)+":"+now.get(Calendar.MINUTE)+":"+now.get(Calendar.SECOND);
0 0
原创粉丝点击