0
点赞
收藏
分享

微信扫一扫

java中获取当前时间

mm_tang 2023-05-15 阅读 50


1] 

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

Calendar now=Calendar.getInstance(); 
String time=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);

 ds

举报

相关推荐

0 条评论