I have a problem with some of my code. I get the date in dd/mm/yyyy format as a string named dateofQ .
I want the date to be yyyy_mm_dd , I use string.split() in the array, but it will not return a third array named myArr [3]:
String[] myArr = dateofQ.split("\\/"); String dateFormat = String.format("%s_%s_%s",myArr[2],myArr[1],myArr[0]);
It returns myArr[1] and myArr[0] , but when I also add myArr[3] , I get a problem at runtime:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2 at ReadFile.main(ReadFile.java:34)
source share