Java 接收String类型的日期参数并转化成Date类型

 

    @RequestMapping(value = {"/list"}, method = RequestMethod.GET)
    @ResponseBody
    public ResponseVO find(@RequestParam(required = false) Long projectId,
                           @RequestParam(required = false) String projectName,
                           @RequestParam(required = false, name = "startTime") String startTimeStr,
                           @RequestParam(required = false, name = "endTime") String endTimeStr) {
        Date startTime = null;
        Date endTime = null;
        if (StringUtils.isNotBlank(startTimeStr)) {
            startTime = SimpleDateUtils.getStartTimeOfDay(
                SimpleDateUtils.parseDate(startTimeStr, SimpleDateUtils.DATE_FORMAT_YYYY_MM_DD_HH_MM_SS_DASH));
        }
        if (StringUtils.isNotBlank(endTimeStr)) {
            endTime = SimpleDateUtils.getEndTimeOfDay(SimpleDateUtils.parseDate(endTimeStr, SimpleDateUtils.DATE_FORMAT_YYYY_MM_DD_HH_MM_SS_DASH));
        }return ReturnUtils.success(taskVOS);
    }

 

posted @ 2018-01-05 10:47  冰凌花花~  阅读(3860)  评论(0编辑  收藏  举报