I'm new to Java and am trying to extract values from a date-related user input string and split it into a DD-MM-YYYY format.
I tried to use the code below:
String inputString = "s.param1";
String[] arraySplit_3 = inputString.split("-");
for (int i=0; i < arraySplit_3.length; i++){
System.out.println(arraySplit_3[i]);
}
s.param1 gets the input of the user, I use a separate excel file for it.
if s.param1 = 15-05-2010
I wish to get this output:
DD: 15
MM: 05
YYYY: 2010
Is there a way to create a method like this?
s.param1for15-05-2010. Seems to be working fine, what's the issue?s.param1is variable so you shouldn't use it in quotes. Otherwise it will be String. But your created method should work when you set date instead ofs.param1.