Calendard的使用

                Scanner scanner new Scanner(System.in);

System.out.println("请输入一个日期:(2008-8-22)");

String dateStr = scanner.nextLine();

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

Date date = sdf.parse(dateStr);

Calendar calendar = Calendar.getInstance();

calendar.setTime(date);

calendar.add(Calendar.YEAR, 3);

calendar.add(Calendar.MONTH, 3);

calendar.add(Calendar.DAY_OF_YEAR, 3);

calendar.add(Calendar.DAY_OF_WEEK, 4);

date = calendar.getTime();

dateStr = sdf.format(date);

System.out.println(dateStr);

你可能感兴趣的:(Calendar,jdbc)