java new Date()字符型转yyyy-MM-dd HH:mm:ss型字符串

public static void main(String[] args) {

		
		String ss = "Mon Aug 06 11:24:59 CST 2012";
		
		
		Date d = new Date(ss);
		
		
		Calendar calendar = Calendar.getInstance();
		
		calendar.setTime(d);
		calendar.add(Calendar.DAY_OF_MONTH, -1);
		calendar.add(Calendar.HOUR_OF_DAY, 10);
		
		
		SimpleDateFormat sdf=  new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		
		String beginTime = sdf.format(calendar.getTime());
		
		System.out.println(beginTime);

		
		
		
	}

你可能感兴趣的:(java)