If mysql has an id, set data to increase by 1. If no id exists, add it. Java month Calculation Comparison, mysql. 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;
The unique constraint id and month are required.
Calculation and comparison of ava months
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 traverses the MONTH int isdel = calDelM. get (Calendar. MONTH); int ix = 8; // The minimum cache MONTH: Calendar ar calDelM2 = Calendar. getInstance (); calDelM2.set (Calendar. MONTH, ix); ix = calDelM2.get (Calendar. MONTH); // ix <isdelCale Ndar 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 ("====================== ");}