- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
- String sDate = simpleDateFormat.format(new Date());
- Date date = null;
- try {
- date = simpleDateFormat.parse(sDate);
- } catch (ParseException e) {
- log.debug("Get Current Date Exception [by ninja.hzw]"+e);
- }
Note here that the MM of the string "yyyy-MM-dd" passed in SimpleDateFormat must be uppercase, otherwise it will be considered that the mm of hours and minutes will not achieve the expected effect.