代码规范笔记

1.不要出现魔法值(数字),定义常量或者枚举

2.防止空指针

3.throws Exception() 表示上层必须try catch捕获

4. 创建new Timestamp(System.currentTimeMillis())

5. timestamp转string

SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
if(timestamp==null){
return "";
}
return df.format(timestamp);
posted @ 2022-10-09 17:52  无极是一种信仰  阅读(14)  评论(0编辑  收藏  举报