| | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | import com.google.gson.JsonSyntaxException; |
| | | import com.whyc.pojo.db_user.UserInf; |
| | | import org.apache.commons.codec.digest.DigestUtils; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | import sun.misc.BASE64Decoder; |
| | |
| | | return new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss").format(c.getTime()); |
| | | } |
| | | |
| | | |
| | | //使用MD5加密 |
| | | public static Object EncryptionMD5(Object obj){ |
| | | String md5=null; |
| | | if(obj!=null && obj.toString().length()>0){ |
| | | md5= DigestUtils.md5Hex(obj.toString()); |
| | | } |
| | | return md5; |
| | | } |
| | | |
| | | //获取时间的年份 |
| | | public static int getDateYear(Date date){ |
| | |
| | | smdate=sdf.parse(sdf.format(smdate)); |
| | | bdate=sdf.parse(sdf.format(bdate)); |
| | | } catch (ParseException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | |
| | | smdate=sdf.parse(sdf.format(smdate)); |
| | | bdate=sdf.parse(sdf.format(bdate)); |
| | | } catch (ParseException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | Calendar cal = Calendar.getInstance(); |
| | |
| | | } |
| | | return lang; |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @return 获取当前session 中的用户对象 |
| | | */ |
| | | public static UserInf getUser(){ |
| | | HttpSession session =getSession(); |
| | | Object obj=session.getAttribute("user"); |
| | | UserInf userInf = new UserInf(); |
| | | if(obj==null){ |
| | | userInf.setUname("未登录的用户账号"); |
| | | userInf.setUid(0); |
| | | }else{ |
| | | userInf=(UserInf) session.getAttribute("user"); |
| | | } |
| | | return userInf; |
| | | } |
| | | } |