//日期转换成字符串
SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd");
String now=format.format(new Date());
System.out.println(now);
String dateStr=format.format(format.parse("2007-12-12"));
System.out.println(dateStr);
//字符串转换成日期
Date date=format.parse("2007-12-12");
System.out.println(date);
//求年月日
Calendar time=Calendar.getInstance();
time.clear();
time.setTime(date);
int year = time.get(Calendar.YEAR);
int month = time.get(Calendar.MONTH) + 1;
int day = time.get(Calendar.DAY_OF_MONTH);
int maxDay=time.getActualMaximum(Calendar.DAY_OF_MONTH);//本月份的天数
System.out.println(year);
System.out.println(month);
System.out.println(day);
System.out.println(maxDay);
柳德才
13691193654
18942949207
QQ:422157370
liudecai_zan@126.com湖北-武汉-江夏-庙山