Commit 627537a7 by zhengxj

finish 新增获取当前日期方法 on 20190129 by zhengxj

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@17163 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 7493ee04
...@@ -26,11 +26,27 @@ public class DateUtil { ...@@ -26,11 +26,27 @@ public class DateUtil {
* *
* @return * @return
*/ */
public static Date getCurrentDate() { public static Date getCurrentTime(){
return new Date(System.currentTimeMillis()); return new Date(System.currentTimeMillis());
} }
/** /**
* 获取当前日期
*
* @return
*/
public static Date getCurrentDate() {
return parseDate(formatDate(getCurrentDate()));
}
public static void main(String args[]){
System.out.println(parseDateYmd(formatDateYmd(getCurrentDate())));
System.out.println(parseDateYmd(getTomorrow()));
}
/**
* 格式化日期 * 格式化日期
* *
* @param date * @param date
...@@ -1063,7 +1079,7 @@ public class DateUtil { ...@@ -1063,7 +1079,7 @@ public class DateUtil {
return monStr; return monStr;
} }
public static void main(String[] args) { public static void main1(String[] args) {
Date today = new Date(); Date today = new Date();
/* /*
//本周第一天日期 //本周第一天日期
...@@ -1181,4 +1197,7 @@ public class DateUtil { ...@@ -1181,4 +1197,7 @@ public class DateUtil {
int days = (int) Math.ceil((double) (endDate.getTime() - beginDate.getTime()) / (1000 * 3600 * 24)); int days = (int) Math.ceil((double) (endDate.getTime() - beginDate.getTime()) / (1000 * 3600 * 24));
return days; return days;
} }
} }
package com.glsx.usercenter.controller; package com.glsx.usercenter.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.glsx.common.constants.ResultObject; import com.glsx.common.constants.ResultObject;
import com.glsx.common.utils.DateUtil; import com.glsx.common.utils.DateUtil;
...@@ -8,15 +24,6 @@ import com.glsx.usercenter.constants.ResultCodeEnum; ...@@ -8,15 +24,6 @@ import com.glsx.usercenter.constants.ResultCodeEnum;
import com.glsx.usercenter.pojo.role.SysRole; import com.glsx.usercenter.pojo.role.SysRole;
import com.glsx.usercenter.pojo.vo.RoleQueryVo; import com.glsx.usercenter.pojo.vo.RoleQueryVo;
import com.glsx.usercenter.service.SysRoleService; import com.glsx.usercenter.service.SysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* @author duanht * @author duanht
...@@ -83,7 +90,7 @@ public class SysRoleController { ...@@ -83,7 +90,7 @@ public class SysRoleController {
if (!sysRoleService.findByRoleName(sysRole.getName()).isEmpty()) { if (!sysRoleService.findByRoleName(sysRole.getName()).isEmpty()) {
return new ResultObject(ResultCodeEnum.FAIL.getCode(), "角色已存在"); return new ResultObject(ResultCodeEnum.FAIL.getCode(), "角色已存在");
} }
sysRole.setCreateTime(DateUtil.getCurrentDate()); sysRole.setCreateTime(DateUtil.getCurrentTime());
//测试 //测试
sysRole.setCreateBy("1"); sysRole.setCreateBy("1");
} }
......
package com.glsx.usercenter.service.impl; package com.glsx.usercenter.service.impl;
import java.util.ArrayList;
import java.util.List;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.glsx.common.utils.DateUtil; import com.glsx.common.utils.DateUtil;
import com.glsx.common.utils.StringUtils; import com.glsx.common.utils.StringUtils;
import com.glsx.usercenter.mapper.SysRoleMapper; import com.glsx.usercenter.mapper.SysRoleMapper;
...@@ -11,13 +20,6 @@ import com.glsx.usercenter.pojo.role.SysRoleExample; ...@@ -11,13 +20,6 @@ import com.glsx.usercenter.pojo.role.SysRoleExample;
import com.glsx.usercenter.pojo.role.SysRoleMenu; import com.glsx.usercenter.pojo.role.SysRoleMenu;
import com.glsx.usercenter.pojo.vo.RoleQueryVo; import com.glsx.usercenter.pojo.vo.RoleQueryVo;
import com.glsx.usercenter.service.SysRoleService; import com.glsx.usercenter.service.SysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;
/** /**
* @author duanht * @author duanht
...@@ -102,7 +104,7 @@ public class SysRoleServiceImpl implements SysRoleService { ...@@ -102,7 +104,7 @@ public class SysRoleServiceImpl implements SysRoleService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public int save(@Valid SysRole sysRole) { public int save(@Valid SysRole sysRole) {
sysRole.setUpdateBy("1"); sysRole.setUpdateBy("1");
sysRole.setUpdateTime(DateUtil.getCurrentDate()); sysRole.setUpdateTime(DateUtil.getCurrentTime());
Integer role_id = null; Integer role_id = null;
if (sysRole.getId() == null || sysRole.getId() == 0) { if (sysRole.getId() == null || sysRole.getId() == 0) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!