[Solved] How to parse date string into integer variables? [duplicate]


        String date = "13-08-2016";
        String[] values = date.split("-");
        int day = Integer.parseInt(values[0]);
        int month = Integer.parseInt(values[1]);
        int year = Integer.parseInt(values[2]);

You can use String.split(String regex) method to parse the date to array of String then convert each value to int.

JavaDoc:

public String[] split(String regex) Splits this string around matches
of the given regular expression. This method works as if by invoking
the two-argument split method with the given expression and a limit
argument of zero. Trailing empty strings are therefore not included in
the resulting array.

Read more here: String.split

solved How to parse date string into integer variables? [duplicate]