Dataformat form1 = new SimpleDateFormat("yyyy-MM-dd"); String birday = req.getParameter("birthday"); Date date = form1.parse(birday);
把String类型的改成date类型
Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); System.out.println(sdf.format(date)); sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); System.out.println(sdf.format(date)); sdf = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss"); System.out.println(sdf.format(date));
把date转成String