substring截取字符串
createTime=20100918094403;Stringyear=createTime.substring(0,4);System.out.println(yea...
createTime = 20100918094403;
String year = createTime.substring(0, 4);
System.out.println(year+"==========");
String month = createTime.substring(4, 2);
System.out.println(month+"==========");
String day = createTime.substring(6, 2);
只能截取出year= 2010
继续截取就会报错java.lang.StringIndexOutOfBoundsException: String index out of range: -2
这是为什么?? 展开
String year = createTime.substring(0, 4);
System.out.println(year+"==========");
String month = createTime.substring(4, 2);
System.out.println(month+"==========");
String day = createTime.substring(6, 2);
只能截取出year= 2010
继续截取就会报错java.lang.StringIndexOutOfBoundsException: String index out of range: -2
这是为什么?? 展开
6个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询