Q:

How to find list of json date is witnin a month or not in android

Sorry for my bad English,I have list of dates coming from json 
{
    "data": [
        {
            "lead_id": "1763",
            "name": "Gaurav Kumar",
            "date": "16-02-2020",
            "time": "10:00 To 11:00 AM",
        },
        {
            "lead_id": "1759",
            "name": "Test",
            "date": "04-02-2020",
            "time": "10:00 To 11:00 AM",
        },
        {
            "lead_id": "1751",
            "name": "kavita sharma",
            "date": "08-02-2020",
            "time": "10:00 To 11:00 AM", 
        },
        {
            "lead_id": "1751",
            "name": "kavita sharma",
            "date": "09-02-2020",
            "time": "10:00 To 11:00 AM",
        }
    ]
}

Below code helps me to find the current date
Calendar calendar = Calendar.getInstance();
        Date today = calendar.getTime();

        @SuppressLint("SimpleDateFormat")
        DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");

        todayAsString = dateFormat.format(today);

        System.out.println(todayAsString);

But i want to know how can i check if the list of date is of the same month.
//Here is the code the i used to check the current date but i want to check if the all dates is of the same months.PLease let me know how could i do this
Retrofit retrofit = new Retrofit.Builder()
                .baseUrl("https://delhidailyservice.com/api/")
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        APIService request = retrofit.create(APIService.class);
        Call<LeadData> call = request.leadData(prefConfig.readLoginId());
        call.enqueue(new Callback<LeadData>() {
            @Override
            public void onResponse(Call<LeadData> call, Response<LeadData> response) {

               /* new Handler().postDelayed(new Runnable() {
                    public void run() {
                        // if (isAdded()) {
                        pDialog.dismiss();
                        // }
                    }
                }, 5000);*/

                pDialog.dismiss();

                LeadData allEvent = response.body();
                allEventData = (List<Leads>) allEvent.getData();
//                Log.d("Error", ""+allEventData.size());

                allEventDatanew.clear();
                for (int i = 0; i < allEventData.size(); i++) {

                    if (todayAsString.equalsIgnoreCase(allEventData.get(i).getDate())) {
                        Leads allevent = new Leads();

                        String service = allEventData.get(i).getService();
                        String date = allEventData.get(i).getDate();
                        String name = allEventData.get(i).getName();
                        String time = allEventData.get(i).getTime();
                        String city = allEventData.get(i).getCity();
                        String status = allEventData.get(i).getStatus();
                        String credit = allEventData.get(i).getCredit();
                        String address = allEventData.get(i).getAddress();
                        String id = allEventData.get(i).getLeadId();

                        try {
                            //String details = allEventData.get(i).getDetail();

                            //abcd = Html.fromHtml(details).toString();

                            // tv_detail.setText(abcd);

                        } catch (Exception e) {
                            e.printStackTrace();
                        }

                        allevent.setService(service);
                        allevent.setDate(date);
                        allevent.setName(name);
                        allevent.setTime(time);
                        allevent.setCity(address + " , " + city);
                        allevent.setStatus(status);
                        allevent.setCredit(credit);
                        allevent.setLeadId(id);

                        allEventDatanew.add(allevent);

                    }

                }
                // Log.d("Error1", ""+allEventDatanew.size());

                individualDataAdapter = new LeadAdapter(allEventDatanew, getContext());

                recyclerViewIndividualEvent.setAdapter(individualDataAdapter);
                individualDataAdapter.notifyDataSetChanged();

A:

java.time and ThreeTenABP
    DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("dd-MM-uuuu");

    List<Leads> allEventData = Arrays.asList(new Leads("16-02-2020"),
            new Leads("04-02-2020"), new Leads("08-02-2020"),
            new Leads("09-02-2020"));

    if (allEventData.isEmpty()) {
        System.out.println("No data");
    } else {
        YearMonth month = YearMonth.parse(allEventData.get(0).getDate(), dateFormatter);
        boolean otherMonthFound = false;
        for (Leads lead : allEventData) {
            if (! YearMonth.parse(lead.getDate(), dateFormatter).equals(month)) {
                otherMonthFound = true;
                break;
            }
        }
        if (otherMonthFound) {
            System.out.println("They are not all in the same month");
        } else {
            System.out.println("They are all in the same month " + month);
        }
    }

Output from this snippet is:

They are all in the same month 2020-02

I left out the other fields from the Leads class I used since they make no difference for the solution.
Question: Doesn’t java.time require Android API level 26?
java.time works nicely on both older and newer Android devices. It just requires at least Java 6.

In Java 8 and later and on newer Android devices (from API level 26) the modern API comes built-in.
In non-Android Java 6 and 7 get the ThreeTen Backport, the backport of the modern classes (ThreeTen for JSR 310; see the links at the bottom).
On (older) Android use the Android edition of ThreeTen Backport. It’s called ThreeTenABP. And make sure you import the date and time classes from org.threeten.bp with subpackages.

Links

Oracle tutorial: Date Time explaining how to use java.time.
Java Specification Request (JSR) 310, where java.time was first described.
ThreeTen Backport project, the backport of java.time to Java 6 and 7 (ThreeTen for JSR-310).
ThreeTenABP, Android edition of ThreeTen Backport
Question: How to use ThreeTenABP in Android Project, with a very thorough explanation.

