Returns the greater of the specified dates. - Java java.util

Java examples for java.util:Date Compare

Description

Returns the greater of the specified dates.

Demo Code

/**//w w  w  . j a  v  a 2 s. c  o  m
 * Copyright (c) 2010 Martin Geisse
 *
 * This file is distributed under the terms of the MIT license.
 */
//package com.java2s;

import java.util.GregorianCalendar;

public class Main {
    /**
     * Returns the greater of the specified dates. The returned object is the same as one
     * of the arguments, not a clone.
     * @param x the first date
     * @param y the second date
     * @return the greater one of the arguments
     */
    public static GregorianCalendar max(GregorianCalendar x,
            GregorianCalendar y) {
        return (x.compareTo(y) > 0) ? x : y;
    }
}

Related Tutorials