请问一下哪里出错了吗?谢谢 输出24天前的日期是正确的 public class GetCurrenTime { public static void main(String[] args) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss SSS"); //返回24天前的时间 //2020-11-10 16-55-04 706 Date date1 = new Date(System.currentTimeMillis() - (1000 * 60 * 60 * 24 * 24)); String time = sdf.format(date1); System.out.println(time); } }
但输出25天前的日期就不对了
public class GetCurrenTime { public static void main(String[] args) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss SSS"); //返回25天前的时间 //2020-12-29 10-00-12 223 Date date1 = new Date(System.currentTimeMillis() - (1000 * 60 * 60 * 24 * 25)); String time = sdf.format(date1); System.out.println(time); } }