728x90
반응형
package test.java; import java.util.ArrayList; import java.util.List; import org.apache.log4j.Logger; public class Test { private static Logger logger = Logger.getLogger(Test.class); public static void main(String[] args) { String selectActivCd = "201307"; String tmp1 = selectActivCd.toString(); String tmp = tmp1.replaceAll("[^\\d]",""); String tmpMinYear = tmp.substring(0, 4); String tmpMinMonth = tmp.substring(4, 6); ArrayList BeforeDfYmList = new ArrayList(); for(int i=37; i>0; i--){ String myIvalue = String.valueOf(i); if (Integer.parseInt(tmpMinMonth) <= 9){ tmpMinMonth = "0" + String.valueOf(Integer.parseInt(tmpMinMonth) + 1); } else { tmpMinMonth = String.valueOf(Integer.parseInt(tmpMinMonth) + 1); } if (tmpMinMonth.equals("13")){ tmpMinYear = String.valueOf(Integer.parseInt(tmpMinYear) +1); tmpMinMonth = "01"; } BeforeDfYmList.add(tmpMinYear.toString() + tmpMinMonth.toString()); } System.out.println(" BeforeDfYmList ==> " + BeforeDfYmList); } }결과값
BeforeDfYmList ==> [201308, 201309, 2013010, 201311, 201312, 201401, 201402, 201403, 201404, 201405, 201406, 201407, 201408, 201409, 2014010, 201411, 201412, 201501, 201502, 201503, 201504, 201505, 201506, 201507, 201508, 201509, 2015010, 201511, 201512, 201601, 201602, 201603, 201604, 201605, 201606, 201607, 201608]
728x90
반응형