public static void main(String[] args) {
String str="08年03月20日";
String st="-";
String sr="";
String date="20";
if(str.indexOf("年")!=-1){
str=str.replace("年", st);
}
if(str.indexOf("月")!=-1){
str=str.replace("月", st);
}
if(str.indexOf("日")!=-1){
str=str.replace("日", sr);
}
System.out.println(date+str);
}
String str="08年03月20日";
String st="-";
String sr="";
String date="20";
if(str.indexOf("年")!=-1){
str=str.replace("年", st);
}
if(str.indexOf("月")!=-1){
str=str.replace("月", st);
}
if(str.indexOf("日")!=-1){
str=str.replace("日", sr);
}
System.out.println(date+str);
}
...
String str="08年03月20日";
DateFormat format=new SimpleDateFormat( "yyyy-MM-dd");
format.parse(str);
System.out.println(str);
java.util.Date strTodate=dateformat.parse(str);
System.out.println(strTodate);
at java.text.DateFormat.parse(DateFormat.java:335)
at business.rptmng.iml.RptMngBiz.main(RptMngBiz.java:201)
骗子 就这也能来骗人!
String s = "08年03月20日";
SimpleDateFormat sdf1 = new SimpleDateFormat("yy年MM月dd日");
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd");
Date date1 = new Date();
String s2 = null;
Date date2 = new Date();
try {
date1 = sdf1.parse(s);
s2 = sdf2.format(date1);
date2 = sdf2.parse(s2);
} catch (ParseException e) {
}
System.out.println(date1);
System.out.println(s2);
System.out.println(date2);
}s2应该是楼主想要的吧