开发者

android/java split problem

开发者 https://www.devze.com 2023-02-03 19:41 出处:网络
String time = starttime.getText().toString(); String[] separated = time.split(\":\"); test.setText(\"HH:\" + separated[0].toString() + \"MM:\" + separated[1].toString());
String time = starttime.getText().toString();

String[] separated = time.split(":");

test.setText("HH:" + separated[0].toString() + "MM:" + separated[1].toString());

If i type in 11:11 in my app, i get arrayoutofboundsexc开发者_如何学Pythoneption. Ive tried trim() on the string as well. Did i miss something?


No, you didn't miss something. I guess, the input misses a colon (:). Double check the format of time right before the split operation.

0

精彩评论

暂无评论...
验证码 换一张
取 消