I have the following problem using the substring() Java function.
I have to do the following operation:
I have a String representing a date having the following form: 2014-12-27 (YEARS-MONTH-DAY).
And I want convert it into a String like this: 20141227 (without the space betwen date component).
So I have implemented the following method that use the substring() method to achieve this task:
private String convertDate(String dataPar) {
String convertedDate = dataPar.substring(0,3) + dataPar.substring(5,6) + dataPar.substring(8,9);
return convertedDate;
}
But it don't work well and return to me wrong conversion. Why? What am I missing?