So, I'm receiving an array of String and I would like to split each element and save it into a new array and I have faced a lot of problems with that and came up with a really bad solution:
String[] timeSlots = { "13:00:00 - 14:00:00", "15:00:00 - 16:00:00","17:00:00 - 18:00:00" };
String[] t = new String[6];
String temp[] = new String[6];
int j = 1;
for (int i = 0; i < 3; i++) {
temp = timeSlots[i].split("\\-");
if(j == 1){
t[0] = temp[0];
t[1] = temp[1].trim();
}
else if(j == 2){
t[2] = temp[0];
t[3] = temp[1].trim();
}
else{
t[4] = temp[0];
t[5] = temp[1].trim();
}
j++;
}
As you can see I have to create an if-statement to save two elements, I know that it's a bad approach but that's all I was able to come with :(