展开全部
使用Calendar类可以对32313133353236313431303231363533e59b9ee7ad9431333365656639日期加、减等操作import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class Add {
public static void main(String[] args) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date now = new Date();
System.out.println("当前时间:" + dateFormat.format(now));
Date newDate = addSeconds(now, 25);
System.out.println("25秒后:" + dateFormat.format(newDate));
}
private static Date addSeconds(Date date, int seconds) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.SECOND, seconds);
return calendar.getTime();
}
}