org.apache.commons.beanutils.locale.converters.DateLocaleConverter Java Examples

The following examples show how to use org.apache.commons.beanutils.locale.converters.DateLocaleConverter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AdminAction.java    From csustRepo with MIT License 4 votes vote down vote up
public String update() {
	
	UserForm userForm=WebUtil.params2FormBean(getParameters(), UserForm.class);
	RepAdmin admin=new RepAdmin();
	
	ConvertUtils.register(new DateLocaleConverter(), Date.class);
	try {
		BeanUtils.copyProperties(admin, userForm);
	} catch (Exception e) {
		e.printStackTrace();
	}

	admin.setUsername(admin.getUsername().trim());
	RepAdmin a=adminService.findAdminByName(admin.getUsername());
	if(a!=null&&!a.getId().equals(admin.getId())){
		getContextMap().put("message", "已经存在同名用户,请换个用户名!");
		getContextMap().put("params", getParameters());
		return "edit";
	}
	
	if(admin.getPassword()!=null&&!admin.getPassword().isEmpty()){
		admin.setPassword(MD5Util.MD5(admin.getPassword()));
	}else {
		admin.setPassword(null);
	}

	int roleid=Integer.parseInt(((String[])getParameters().get("roleid"))[0]);
	
	//判断更新的管理员是否是最后的一个未锁定的超级管理员,如果是的话则不能删除
	RepRole role=roleService.get(roleid);
	RepRole originalRole=adminService.get(admin.getId()).getRepRole();
	//判断是否符合最后一个超级管理员的条件
	if(originalRole!=null&&originalRole.getName().equals("超级管理员")
			//如果是最后一个超级管理员,则判断是否进行了修改角色或锁定操作
			&&(!role.getName().equals("超级管理员")||admin.getIslock()==1)){

		int size=adminService.countUnLockSuperAdmins();
		if(size<=1){
			getContextMap().put("message", "不能对最后一个超级管理员进行锁定或者修改角色的操作!");
			getContextMap().put("returnUrl", getRequest().getContextPath()+"/admin/user/admin_list.do");
			return "faild";
		}
	}
	
	admin.setRepRole(role);
	
	adminService.updateNotNullField(admin);
	getContextMap().put("message", "修改成功");
	getContextMap().put("returnUrl", "admin_list.do");
	
	return SUCCESS;
}
 
Example #2
Source File: ConvertUtil.java    From feilong-core with Apache License 2.0 2 votes vote down vote up
/**
 * Register simple date locale converter.
 *
 * @param pattern
 *            the pattern
 * @since 1.11.2
 */
public static void registerSimpleDateLocaleConverter(String pattern){
    DateLocaleConverter dateLocaleConverter = new DateLocaleConverter(null, Locale.getDefault(), pattern);
    ConvertUtils.register(dateLocaleConverter, Date.class);
}