0

In my Java code (Android Studio) I have an ArrayList() dynamically created (the size of the ArrayList is not fixed). Something like:

[Name, January 2, 2020, 9:00 a.m. – 11:00 p.m., Name, Name, February 3, 2020, 9:00 a.m. – 11:00 p.m., name, Name, August 4, 2020, 9:00 a.m. – 11:00 p.m., Name, Name]

now, is it possible to search only for dates (so recognize which are dates) and then substitute in another format?

I would like, for example, Jan 2, 2020 -> 01/02/20.

My idea is scroll the ArrayList, filter the items with a switch case and then do "something" in the specific date data, but still no idea how and maybe switch case cannot search for partial matches, I'm afraid. Like,

switch (arraytest) {

                case "January":
                case "February":
                case "March":
                case "April":
                case "May":
                case "June":
                case "July":
                case "August":
                case "September":
                case "October":
                case "November":
                case "December":

                    arraytest = arraytest.something...

                    break;
            }

Thanks for the help

Andry
  • 323
  • 1
  • 2
  • 10

1 Answers1

0

I don't think I got what exactly you are trying to do, but you can convert the date string into date type then reformate it as you wish. I hope that useful.

Ala'a Eng
  • 47
  • 1
  • 7
  • Substantially, I have an ArrayList with several strings. Some of these strings are in the format "Month Day, Year", others are name. I would like to find only the items with "Month Day, Year" and then convert all of them from this format to MM/DD/YY. – Andry Nov 03 '20 at 17:27
  • Do you know the order of it? – Ala'a Eng Nov 03 '20 at 19:43
  • Or can you stor them on objects? Then you can just object.date for ex – Ala'a Eng Nov 03 '20 at 19:46