public static void main(String[] args) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, calendar.get(Calendar.HOUR_OF_DAY) - 10); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); System.out.println("一个小时前:" + df.format(calendar.getTime())); System.out.println("当前的时间:" + df.format(new Date())); }
时间: 2024-11-05 13:10:02