0

I'm trying to split a date string in the format of day.month.year

The code i'm using is

String[] dates = date.split(".");

For the input string "24.05.21" i'd expect to get a dates.length of 3, but i'm getting 0

Full code

System.out.println("codesList:" + codesList.get(0));
            String date = codesList.get(0).replace("Codes ", "");
            System.out.println("Date:" + date);
            String[] dates = date.split("."); // day . month . year
            System.out.println("Dates:" + dates.length);

codesList:Codes 24.05.21

Date:24.05.21

Dates:0

Ceri Turner
  • 830
  • 2
  • 12
  • 36

0 Answers0