Java Calendar Compare minCalendars(List calendars)

Here you can find the source of minCalendars(List calendars)

Description

Returns the minimum Calendar in the Calendar list.

License

Open Source License

Parameter

Parameter Description
calendars the list of Calendar to calculate the minimum.

Return

the minimum calendar in the Calendar list.

Declaration

public static Calendar minCalendars(List<Calendar> calendars) 

Method Source Code


//package com.java2s;
import java.util.Calendar;

import java.util.List;

public class Main {
    /**//  w  ww .  jav a2 s.c o m
     * Returns the minimum Calendar in the Calendar list.
     *
     * @param calendars the list of Calendar to calculate the minimum.
     * @return the minimum calendar in the Calendar list.
     */
    public static Calendar minCalendars(List<Calendar> calendars) {
        long min = Long.MAX_VALUE;
        Calendar minCalendar = null;
        for (Calendar value : calendars) {
            long v = value.getTimeInMillis();
            if (v < min) {
                min = v;
                minCalendar = value;
            }
        }
        return minCalendar;
    }
}

Related

  1. isSameInstant(Calendar cal1, Calendar cal2)
  2. isSameInstant(final Calendar cal1, final Calendar cal2)
  3. max(Calendar cal1, Calendar cal2)
  4. min(Calendar c1, Calendar c2)
  5. min(final Calendar... calendars)
  6. minimum(Calendar... calendars)