Java Date Before isBefore(Date date1, Date date2)

Here you can find the source of isBefore(Date date1, Date date2)

Description

is Before

License

Mozilla Public License

Declaration

public static boolean isBefore(Date date1, Date date2) 

Method Source Code

//package com.java2s;
/* This file is part of the MayDesk project.
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.*///  ww  w .j  a  v a2 s .  co  m

import java.util.Calendar;
import java.util.Date;

public class Main {
    public static boolean isBefore(Date date1, Date date2) {
        Calendar cal1 = Calendar.getInstance();
        cal1.setTime(date1);
        cal1.set(Calendar.HOUR, 0);
        cal1.set(Calendar.MINUTE, 0);
        cal1.set(Calendar.SECOND, 0);
        Calendar cal2 = Calendar.getInstance();
        cal1.setTime(date1);
        cal1.set(Calendar.HOUR, 0);
        cal1.set(Calendar.MINUTE, 0);
        cal1.set(Calendar.SECOND, 0);
        return cal1.before(cal2);
    }
}

Related

  1. getPreviousDate(String before)
  2. getQuarterStartDateBeforeCurrent(int num, Date current)
  3. getSomeDaysBeforeAfter(Date date, int days)
  4. isAtLeastOneDayBefore(Date daybefore, Date dayafter)
  5. isBefore(Date date)
  6. isBefore2015(Date date)
  7. isBefore_day(Date time1, Date time2, int days)
  8. isBeforeCommonEra(Date date)
  9. isBeforeDate(long time1, long time2)