mysql 假设存在id则设数据自添加1 ,不存在则加入。java月份计算比較

</pre><pre name="code" class="sql">INSERT INTO invite_rejectlog_num (
player_id,
MONTH,
count,
last_modify_time
)
VALUES (#{playerId},#{month},#{count},#{lastModifyTime})
ON DUPLICATE KEY UPDATE count=count+1;

须要唯一约束 id和月份

ava月份计算比較

Calendar calDelM = Calendar.getInstance();
calDelM.set(Calendar.MONTH, 0);
System.out.println(calDelM.get(Calendar.MONTH)); calDelM.add(Calendar.MONTH, -1);
System.out.println(calDelM.get(Calendar.MONTH)); // ix 遍历须要删除的月份
int isdel = calDelM.get(Calendar.MONTH);
int ix = 8;// 缓存最小月份 Calendar calDelM2 = Calendar.getInstance();
calDelM2.set(Calendar.MONTH, ix);
ix = calDelM2.get(Calendar.MONTH); // ix<isdel
Calendar calDelM3 = Calendar.getInstance();
calDelM3.set(Calendar.MONTH, calDelM.get(Calendar.MONTH)); for (; calDelM2.compareTo(calDelM3) != -1;) { System.out.println("================");
System.out.println("calDelM2:" + calDelM2.get(Calendar.MONTH) + " "
+ " calDelM:" + calDelM.get(Calendar.MONTH)+ " calDelM3: " + calDelM3.get(Calendar.MONTH));
System.out.println(calDelM2.compareTo(calDelM3)); calDelM.add(Calendar.MONTH, -1);
isdel = calDelM.get(Calendar.MONTH);
calDelM3.set(Calendar.MONTH, calDelM.get(Calendar.MONTH)); System.out.println("del:" + isdel);
System.out.println("================");
}
上一篇:android平台的三个编译命令——make,mm,mmm


下一篇:Springboot的常规属性配置和类型安全配置