Java Calendar Year isSameDayOfYear(Calendar calendar1, Calendar calendar2)

Here you can find the source of isSameDayOfYear(Calendar calendar1, Calendar calendar2)

Description

is Same Day Of Year

License

Open Source License

Declaration

public static boolean isSameDayOfYear(Calendar calendar1, Calendar calendar2) 

Method Source Code


//package com.java2s;
/*//w ww . ja v  a  2  s  . co m
 * Copyright 2009 Yodlee, Inc.  All Rights Reserved.  Your use of this code 
 * requires a license from Yodlee.  Any such license to this code is 
 * restricted to evaluation/illustrative purposes only. It is not intended 
 * for use in a production environment, and Yodlee disclaims all warranties 
 * and/or support obligations concerning this code, regardless of the terms 
 * of any other agreements between Yodlee and you."
 */

import java.util.Calendar;

public class Main {
    public static boolean isSameDayOfYear(Calendar calendar1, Calendar calendar2) {

        return (getYear(calendar1) == getYear(calendar2)) && (getDay(calendar1) == getDay(calendar2));
    }

    public static int getYear(Calendar calendar) {
        return calendar.get(Calendar.YEAR);
    }

    public static int getDay(Calendar calendar) {
        return calendar.get(Calendar.DAY_OF_YEAR);
    }
}

Related

  1. getYear(Date date, Calendar cal)
  2. getYearForWeek(final Calendar cal)
  3. getYearList(Calendar currDate)
  4. isBeforeDay(Calendar date1, Calendar date2, boolean ignoreYear)
  5. isSameDay(Calendar date1, Calendar date2, boolean ignoreYear)
  6. isSameWeekOfYear(Calendar calendar1, Calendar calendar2)
  7. isToThisDayOrLater(int year, int month, int day, java.util.Calendar start, java.util.Calendar end)
  8. isWithinYears(int year, java.util.Calendar start, java.util.Calendar end)
  9. parseCalendar(int year, int month, double day, TimeZone zone)