java 获取秒数

public static String parseTimeMillis(String time) throws Exception{
		if(time==null || "".equals(time)){
			time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
		}
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Date date = sdf.parse(time);
		String s = String.valueOf(date.getTime());
		return s.substring(0, s.length()-3);
	}

 

posted @ 2017-09-26 10:57  Djokovic  阅读(1393)  评论(0编辑  收藏  举报