现在的位置: 首页 > 综合 > 正文

java 获取当前时间

2013年12月19日 ⁄ 综合 ⁄ 共 358字 ⁄ 字号 评论关闭

SimpleDateFormat tempDate = new SimpleDateFormat("yyyy-MM-dd" + " " + "hh:mm:ss");

  String datetime = tempDate.format(new java.util.Date());

  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);

抱歉!评论已关闭.