public class Demo {
public static void main(String[] args) {
String str = "2015-09-11";
//取出这个字符中的年月日信息
String year = str.substring(0,str.indexOf("-"));//年
int index = str.indexOf("-");
int start = index + 1;
// int end = str.lastIndexOf("-");
int end = str.indexOf("-",start);
String month = str.substring(start,end);//月
String day = str.substring(str.lastIndexOf("-") + 1);//日
System.out.println(year + "," + month + "," + day);
}
}
|
|