优化Code的自己小心得


问题五:不能使用 new Date().getTime()

I解决方案:请使用System.currentTimeMillis()代替new Date().getTime()

问题一:避免在方法体中使用pattern.compile

解决问题方案:

先将private static Pattern NUMBER_PATTERN = Pattern.compile(" |\r| ");然后使用

NUMBER_PATTERN.matcher()调用方法


问题二:避免用Apache 的BeanUtils.copyProperties方法

I解决问题方案:

采用spring的BeanUtils.copyProperties()方法 import org.springframework.beans.BeanUtils;

问题三:不能直接Timer timer = new Timer();

解决问题方案:

使用ScheduledExecutorService代替Timer



发表评论
留言与评论(共有 0 条评论) “”
   
验证码:

相关文章

推荐文章