从用户输入取到日期格式yyyy-MM-dd,如何格式化为yyyyMMdd
迷糊了,公司太热了。。。
------解决方案--------------------String s1 = "2007-03-15 ";
String s2 = s1.substring(0, 4) + s1.substring(5, 7) + s1.substring(8, 10);
System.out.println(s2);
------解决方案--------------------String str = "2007-08-10 ";
SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd ");
SimpleDateFormat sdf1 = new SimpleDateFormat( "yyyyMMdd ");
try {
String result = sdf1.format(sdf.parse(str));
System.out.println( "result = " + result);
} catch(Exception ex) {
}