Filter an Arraylist in different Arrays

Viewed 276

I want to filter a single array into parts. Suppose I have an ArrayList of String :

 Array1  = ["2015-01-06","2015-04-06",
    "2016-06-06","2016-01-06",
    "2016-05-06","2017-02-06",
    "2017-04-06","2017-03-06",
    "2015-03-06","2016-04-06",
    "2016-02-06","2015-05-06",
    "2015-01-06","2016-06-06"]

I want it to filter in new arrays according to their years, so that the output will look like :

arrayA = ["2015-01-06","2015-04-06","2015-03-06","2015-05-06","2015-01-06"]
arrayB = ["2016-06-06","2016-01-06","2016-05-06","2016-04-06","2016-02-06","2016-06-06"]
arrayC = [""2017-02-06","2017-04-06","2017-03-06""]

The arrays are based on years now. I don't know the proper way for accomplishing this task.

3 Answers
Related