String time = "2018-08-04 02:30:00";
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar calendar = Calendar.getInstance();
try {
calendar.setTime(df.parse(time));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
calendar.add(Calendar.SECOND, -30);
System.out.println(df.format(calendar.getTime()));
————————————————
版权声明:本文为CSDN博主「hadoove」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/u013817676/article/details/93115321
原文地址:https://www.cnblogs.com/sunjian43792901/p/11577816.html
时间: 2024-10-11 13:58:37