------解决方案-------------------- Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); String dateStr = sdf.format(date); System.out.println(dateStr);
------解决方案-------------------- Date date = new Date(); long time = date.getTime(); time = time - 1000 * 3600 * 24 * 7; Date newDate = new Date(time);
------解决方案-------------------- Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.WEEK, -1); Date d = calendar.getTime();
------解决方案-------------------- Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.WEEK, 1); Date d = calendar.getTime();
------解决方案-------------------- Calendar c = Calendar.getInstance(); c.set(Calendar.DAY_OF_MONTH,c.get(Calendar.DAY_OF_MONTH) - 7); Date date = c.getTime(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String dateStr = sdf.format(date); System.out.println(dateStr);
------解决方案--------------------