Java Calendar Day getGregorianDay(Calendar cal)

Here you can find the source of getGregorianDay(Calendar cal)

Description

get Gregorian Day

License

Open Source License

Declaration

public static int getGregorianDay(Calendar cal) 

Method Source Code

//package com.java2s;
/**//w  w  w.j  a v a2  s .  co  m
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

import java.util.Calendar;

public class Main {
    public static int getGregorianDay(Calendar cal) {
        int year = cal.get(Calendar.YEAR) - 1600;

        int month = cal.get(Calendar.MONTH) + 1;

        if (month < 3) {
            month += 12;
        }

        int day = cal.get(Calendar.DATE);

        int gregorianDay = (int) (6286 + (year * 365.25) - (year / 100) + (year / 400) + (30.6 * month) + 0.2
                + day);

        return gregorianDay;
    }
}

Related

  1. getEndDay(Calendar cal)
  2. getEndOfDay(Calendar c)
  3. getEndOfDay(Date date, Calendar cal)
  4. getEndOfTodayAsCalendar()
  5. getFirstDay(Calendar cal)
  6. getJulianDay(Calendar currentDate)
  7. getLastDay(Date targetDate, Calendar cal)
  8. getLastDayOfPreviousPeriod(int startDayOfPeriod, Calendar cal)
  9. getMonday(Calendar calendar)