Java 得到指定时间加半个小时之后得时间

时间:2023-02-01 03:16:26

Calendar c = Calendar.getInstance();
c.setTime(cur); //设置时间
c.add(Calendar.MINUTE, 1); //日期分钟加1,Calendar.DATE(天),Calendar.HOUR(小时)
Date date = c.getTime(); //结果

Calendar cal = Calendar.getInstance();
cal.setTime(d1);
cal.add(Calendar.MINUTE, 30);
Date d2 = cal.getTime();