获得指定日期的前一天

 

 * 获得指定日期的前一天 
	 * @param specifiedDay 
	 * @return 
	 * @throws Exception 
	 */ 
	 public static String getSpecifiedDayBefore(String specifiedDay){ 
	 //SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); 
		 
		 System.out.println("specifiedDay===================>"+specifiedDay);
	 Calendar c = Calendar.getInstance(); 
	 Date date=null; 
	 try { 
	 date = new SimpleDateFormat("yy/MM/dd").parse(specifiedDay); 
	 } catch (ParseException e) { 
	 e.printStackTrace(); 
	 } 
	 c.setTime(date); 
	 int day=c.get(Calendar.DATE); 
	 c.set(Calendar.DATE,day-1); 

	 String dayBefore=new SimpleDateFormat("yyyy年MM月dd日").format(c.getTime()); 
	 
	 
	 
	 return dayBefore; 
	 } 

 

你可能感兴趣的:(java基础)