我在android中有项目,我需要拆分字符串,这实际上是日期,这是我要拆分的字符串:
String datetime = "01/03/2013 09:00";
这就是我所说的:
int year = splitDateTime(dateTime)[0];
public int[] splitDateTime(String datetime){
String date_time = datetime;
String delimiter = "//:";
String[] sParts;
int[] intParts;
sParts = date_time.split(delimiter);
intParts = new int[sParts.length];
for(int i =0; i < sParts.length ; i++)
intParts[i] = Integer.parseInt(sParts[i]);
return intParts;
}
但它一直给我一个错误,所以如果你能帮助我,我会很高兴。干杯