java 定义三分钟之前的时间

时间:2019-04-10 20:04:23   收藏:0   阅读:199

public String getCurrentTime(){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
   Calendar beforeTime = Calendar.getInstance();
   beforeTime.add(Calendar.MINUTE, -3);// 3分钟之前的时间
   Date beforeD = beforeTime.getTime();
   String time = sdf.format(beforeD);
return time;
}

原文:https://www.cnblogs.com/leigepython/p/10685502.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!