1、获取指定时间之后的几分钟
public static String getFiveMinAfter(String time) throws ParseException {
SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Date date = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").parse(time);
Calendar now = Calendar.getInstance();
now.setTime(date);
now.add(Calendar.MINUTE,8);
Date afterFiveMin = now.getTime();
return format.format(afterFiveMin);
}
2、获取指定时间与当前时间的间隔毫秒数
public static Integer diff(String time) throws ParseException {
SimpleDateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
long currentTime =System.currentTimeMillis();
long createTime = df.parse(time).getTime();
long diff=(currentTime-createTime)/1000/60;
return Integer.parseInt(String.valueOf(diff));
}
版权声明:本文为qq_36811160原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。