1 package com.wages.salary.service.common; 2 3 import java.text.SimpleDateFormat; 4 import java.util.Date; 5 6 public class DateUtil { 7 public static String getDate() { 8 Date date = new Date(); 9 SimpleDateFormat sf = new SimpleDateFormat("yyyyMM"); 10 String s = sf.format(date); 11 //String s="201401"; 12 String year=s.substring(0,4); 13 String month =s.substring(4,6); 14 int result=0; 15 if(month.equals("01")){ 16 int yearInt=Integer.parseInt(year)-1; 17 int monthInt=12; 18 result=yearInt*100+monthInt; 19 }else{ 20 result=Integer.parseInt(year+month)-1; 21 } 22 return String.valueOf(result); 23 //System.out.println(result); 24 } 25 }
201410------>201409
201401------>201312