java.util.Calendar#DECEMBER源码实例Demo

下面列出了java.util.Calendar#DECEMBER 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: cathode   文件: Utils.java
public static int getDaysInMonth(int month, int year) {
    switch (month) {
        case Calendar.JANUARY:
        case Calendar.MARCH:
        case Calendar.MAY:
        case Calendar.JULY:
        case Calendar.AUGUST:
        case Calendar.OCTOBER:
        case Calendar.DECEMBER:
            return 31;
        case Calendar.APRIL:
        case Calendar.JUNE:
        case Calendar.SEPTEMBER:
        case Calendar.NOVEMBER:
            return 30;
        case Calendar.FEBRUARY:
            return (year % 4 == 0) ? 29 : 28;
        default:
            throw new IllegalArgumentException("Invalid Month");
    }
}
 
public static int getDaysInMonth(int month, int year) {
    switch (month) {
        case Calendar.JANUARY:
        case Calendar.MARCH:
        case Calendar.MAY:
        case Calendar.JULY:
        case Calendar.AUGUST:
        case Calendar.OCTOBER:
        case Calendar.DECEMBER:
            return 31;
        case Calendar.APRIL:
        case Calendar.JUNE:
        case Calendar.SEPTEMBER:
        case Calendar.NOVEMBER:
            return 30;
        case Calendar.FEBRUARY:
            return (year % 4 == 0) ? 29 : 28;
        default:
            throw new IllegalArgumentException("Invalid Month");
    }
}
 
源代码3 项目: MonthAndYearPicker   文件: MonthPickerDialog.java
/**
 * Set the Minimum, maximum enabled months and starting , ending years.
 *
 * @param minMonth minimum enabled month in picker
 * @param maxMonth maximum enabled month in picker
 * @param minYear  starting year
 * @param maxYear  ending year
 * @return
 */
public Builder setMonthAndYearRange(@IntRange(from = Calendar.JANUARY, to = Calendar.DECEMBER)
                                            int minMonth,
                                    @IntRange(from = Calendar.JANUARY, to = Calendar.DECEMBER)
                                            int maxMonth,
                                    int minYear, int maxYear) {
    if (minMonth >= Calendar.JANUARY && minMonth <= Calendar.DECEMBER &&
            maxMonth >= Calendar.JANUARY && maxMonth <= Calendar.DECEMBER) {
        this._minMonth = minMonth;
        this._maxMonth = maxMonth;

    } else {
        throw new IllegalArgumentException("Month range should be between 0 " +
                "(Calender.JANUARY) to 11 (Calendar.DECEMBER)");
    }

    if (minYear <= maxYear) {
        this._minYear = minYear;
        this._maxYear = maxYear;
    } else {
        throw new IllegalArgumentException("Minimum year should be less then Maximum year");
    }
    return this;
}
 
源代码4 项目: Music-Player   文件: CalendarUtil.java
/**
 * Returns the time elapsed so far this month and the last numMonths months in milliseconds.
 *
 * @param numMonths Additional number of months prior to the current month to calculate.
 * @return Time elapsed this month and the last numMonths months in milliseconds.
 */
public long getElapsedMonths(int numMonths) {
    // Today + rest of this month
    long elapsed = getElapsedMonth();

    // Previous numMonths months
    int month = calendar.get(Calendar.MONTH);
    int year = calendar.get(Calendar.YEAR);
    for (int i = 0; i < numMonths; i++) {
        month--;

        if (month < Calendar.JANUARY) {
            month = Calendar.DECEMBER;
            year--;
        }

        elapsed += getDaysInMonth(year, month) * MS_PER_DAY;
    }

    return elapsed;
}
 
源代码5 项目: RipplePower   文件: Week.java
public Week(Date time, TimeZone zone, Locale locale) {
	Calendar calendar = Calendar.getInstance(zone, locale);
	calendar.setTime(time);

	int tempWeek = calendar.get(Calendar.WEEK_OF_YEAR);
	if (tempWeek == 1 && calendar.get(Calendar.MONTH) == Calendar.DECEMBER) {
		this.week = 1;
		this.year = (short) (calendar.get(Calendar.YEAR) + 1);
	} else {
		this.week = (byte) Math.min(tempWeek, LAST_WEEK_IN_YEAR);
		int yyyy = calendar.get(Calendar.YEAR);
		if (calendar.get(Calendar.MONTH) == Calendar.JANUARY && this.week >= 52) {
			yyyy--;
		}
		this.year = (short) yyyy;
	}
	peg(calendar);
}
 
源代码6 项目: olat   文件: WeeklyCalendarComponent.java
/**
 * Set focus of calendar-component to certain date. Calculate correct week-of-year and year for certain date.
 * 
 * @param gotoDate
 */
public void setDate(final Date gotoDate) {
    final Calendar cal = CalendarUtils.createCalendarInstance(getTranslator().getLocale());
    cal.setTime(gotoDate);
    int weekYear = cal.get(Calendar.YEAR);
    final int week = cal.get(Calendar.WEEK_OF_YEAR);
    if (week == 1) {
        // Week 1 is a special case: the date could be the last days of december, but the week is still counted as week one of the next year. Use the next year in
        // this case to match the week number.
        if (cal.get(Calendar.MONTH) == Calendar.DECEMBER) {
            weekYear++;
        }
    } else if (week >= 52) {
        // Opposite check: date could be first days of january, but the week is still counted as the last week of the passed year. Use the last year in this case to
        // match the week number.
        if (cal.get(Calendar.MONTH) == Calendar.JANUARY) {
            weekYear--;
        }
    }
    setFocus(weekYear, week);
}
 
源代码7 项目: AirCalendar   文件: CalendarUtils.java
public static int getDaysInMonth(int month, int year) {
       switch (month) {
           case Calendar.JANUARY:
           case Calendar.MARCH:
           case Calendar.MAY:
           case Calendar.JULY:
           case Calendar.AUGUST:
           case Calendar.OCTOBER:
           case Calendar.DECEMBER:
               return 31;
           case Calendar.APRIL:
           case Calendar.JUNE:
           case Calendar.SEPTEMBER:
           case Calendar.NOVEMBER:
               return 30;
           case Calendar.FEBRUARY:
               return ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) ? 28 : 29;
           default:
               throw new IllegalArgumentException("Invalid Month");
       }
}
 
源代码8 项目: CustomizableCalendar   文件: DateUtils.java
public static int getDaysInMonth(int month, int year) {
    switch (month) {
        case Calendar.JANUARY:
        case Calendar.MARCH:
        case Calendar.MAY:
        case Calendar.JULY:
        case Calendar.AUGUST:
        case Calendar.OCTOBER:
        case Calendar.DECEMBER:
            return 31;
        case Calendar.APRIL:
        case Calendar.JUNE:
        case Calendar.SEPTEMBER:
        case Calendar.NOVEMBER:
            return 30;
        case Calendar.FEBRUARY:
            return (year % 4 == 0) ? 29 : 28;
        default:
            throw new IllegalArgumentException("Invalid Month");
    }
}
 
源代码9 项目: ClockPlus   文件: Utils.java
public static int getDaysInMonth(int month, int year) {
    switch (month) {
        case Calendar.JANUARY:
        case Calendar.MARCH:
        case Calendar.MAY:
        case Calendar.JULY:
        case Calendar.AUGUST:
        case Calendar.OCTOBER:
        case Calendar.DECEMBER:
            return 31;
        case Calendar.APRIL:
        case Calendar.JUNE:
        case Calendar.SEPTEMBER:
        case Calendar.NOVEMBER:
            return 30;
        case Calendar.FEBRUARY:
            return (year % 4 == 0) ? 29 : 28;
        default:
            throw new IllegalArgumentException("Invalid Month");
    }
}
 
源代码10 项目: UltimateAndroid   文件: CalendarUtils.java
public static int getDaysInMonth(int month, int year) {
       switch (month) {
           case Calendar.JANUARY:
           case Calendar.MARCH:
           case Calendar.MAY:
           case Calendar.JULY:
           case Calendar.AUGUST:
           case Calendar.OCTOBER:
           case Calendar.DECEMBER:
               return 31;
           case Calendar.APRIL:
           case Calendar.JUNE:
           case Calendar.SEPTEMBER:
           case Calendar.NOVEMBER:
               return 30;
           case Calendar.FEBRUARY:
               return (year % 4 == 0) ? 29 : 28;
           default:
               throw new IllegalArgumentException("Invalid Month");
       }
}
 
源代码11 项目: MineLittlePony   文件: ChristmasHat.java
private static boolean isChristmasDay() {
    if (!dayChecked) {
        dayChecked = true;
        Calendar cal = Calendar.getInstance();
        dayResult = cal.get(Calendar.MONTH) == Calendar.DECEMBER
                 && cal.get(Calendar.DAY_OF_MONTH) == 25;
    }


    return dayResult;
}
 
源代码12 项目: buffer_bci   文件: Week.java
/**
 * Creates a time period for the week in which the specified date/time
 * falls, calculated relative to the specified time zone.
 *
 * @param time  the date/time (<code>null</code> not permitted).
 * @param zone  the time zone (<code>null</code> not permitted).
 * @param locale  the locale (<code>null</code> not permitted).
 *
 * @since 1.0.7
 */
public Week(Date time, TimeZone zone, Locale locale) {
    ParamChecks.nullNotPermitted(time, "time");
    ParamChecks.nullNotPermitted(zone, "zone");
    ParamChecks.nullNotPermitted(locale, "locale");
    Calendar calendar = Calendar.getInstance(zone, locale);
    calendar.setTime(time);

    // sometimes the last few days of the year are considered to fall in
    // the *first* week of the following year.  Refer to the Javadocs for
    // GregorianCalendar.
    int tempWeek = calendar.get(Calendar.WEEK_OF_YEAR);
    if (tempWeek == 1
            && calendar.get(Calendar.MONTH) == Calendar.DECEMBER) {
        this.week = 1;
        this.year = (short) (calendar.get(Calendar.YEAR) + 1);
    }
    else {
        this.week = (byte) Math.min(tempWeek, LAST_WEEK_IN_YEAR);
        int yyyy = calendar.get(Calendar.YEAR);
        // alternatively, sometimes the first few days of the year are
        // considered to fall in the *last* week of the previous year...
        if (calendar.get(Calendar.MONTH) == Calendar.JANUARY
                && this.week >= 52) {
            yyyy--;
        }
        this.year = (short) yyyy;
    }
    peg(calendar);
}
 
源代码13 项目: QuickShop-Reremake   文件: FunnyEasterEgg.java
private boolean chineseSpringDay() {
    Date chineseCalender = new LunarCalendar(new Date()).getDate();
    if (chineseCalender.getMonth() == Calendar.DECEMBER && chineseCalender.getDay() == 31) {
        return true;
    }
    return chineseCalender.getMonth() == Calendar.JANUARY && chineseCalender.getDay() == 1;
}
 
源代码14 项目: coming   文件: Elixir_005_t.java
/**
 * Creates a time period for the week in which the specified date/time
 * falls, calculated relative to the specified time zone.
 *
 * @param time  the date/time (<code>null</code> not permitted).
 * @param zone  the time zone (<code>null</code> not permitted).
 * @param locale  the locale (<code>null</code> not permitted).
 *
 * @since 1.0.7
 */
public Week(Date time, TimeZone zone, Locale locale) {
    if (time == null) {
        throw new IllegalArgumentException("Null 'time' argument.");
    }
    if (zone == null) {
        throw new IllegalArgumentException("Null 'zone' argument.");
    }
    if (locale == null) {
        throw new IllegalArgumentException("Null 'locale' argument.");
    }
    Calendar calendar = Calendar.getInstance(zone, locale);
    calendar.setTime(time);

    // sometimes the last few days of the year are considered to fall in
    // the *first* week of the following year.  Refer to the Javadocs for
    // GregorianCalendar.
    int tempWeek = calendar.get(Calendar.WEEK_OF_YEAR);
    if (tempWeek == 1
            && calendar.get(Calendar.MONTH) == Calendar.DECEMBER) {
        this.week = 1;
        this.year = (short) (calendar.get(Calendar.YEAR) + 1);
    }
    else {
        this.week = (byte) Math.min(tempWeek, LAST_WEEK_IN_YEAR);
        int yyyy = calendar.get(Calendar.YEAR);
        // alternatively, sometimes the first few days of the year are
        // considered to fall in the *last* week of the previous year...
        if (calendar.get(Calendar.MONTH) == Calendar.JANUARY
                && this.week >= 52) {
            yyyy--;
        }
        this.year = (short) yyyy;
    }
    peg(calendar);
}
 
源代码15 项目: ECG-Viewer   文件: Week.java
/**
 * Creates a time period for the week in which the specified date/time
 * falls, calculated relative to the specified time zone.
 *
 * @param time  the date/time (<code>null</code> not permitted).
 * @param zone  the time zone (<code>null</code> not permitted).
 * @param locale  the locale (<code>null</code> not permitted).
 *
 * @since 1.0.7
 */
public Week(Date time, TimeZone zone, Locale locale) {
    ParamChecks.nullNotPermitted(time, "time");
    ParamChecks.nullNotPermitted(zone, "zone");
    ParamChecks.nullNotPermitted(locale, "locale");
    Calendar calendar = Calendar.getInstance(zone, locale);
    calendar.setTime(time);

    // sometimes the last few days of the year are considered to fall in
    // the *first* week of the following year.  Refer to the Javadocs for
    // GregorianCalendar.
    int tempWeek = calendar.get(Calendar.WEEK_OF_YEAR);
    if (tempWeek == 1
            && calendar.get(Calendar.MONTH) == Calendar.DECEMBER) {
        this.week = 1;
        this.year = (short) (calendar.get(Calendar.YEAR) + 1);
    }
    else {
        this.week = (byte) Math.min(tempWeek, LAST_WEEK_IN_YEAR);
        int yyyy = calendar.get(Calendar.YEAR);
        // alternatively, sometimes the first few days of the year are
        // considered to fall in the *last* week of the previous year...
        if (calendar.get(Calendar.MONTH) == Calendar.JANUARY
                && this.week >= 52) {
            yyyy--;
        }
        this.year = (short) yyyy;
    }
    peg(calendar);
}
 
源代码16 项目: The-5zig-Mod   文件: SnowRenderer.java
public SnowRenderer() {
	Calendar calendar = Calendar.getInstance();

	render = (calendar.get(Calendar.MONTH) == Calendar.DECEMBER && calendar.get(Calendar.DAY_OF_MONTH) >= 15) || (calendar.get(Calendar.MONTH) == Calendar.JANUARY && calendar.get(
			Calendar.DAY_OF_MONTH) <= 15);
}
 
源代码17 项目: The-5zig-Mod   文件: SnowRenderer.java
public SnowRenderer() {
	Calendar calendar = Calendar.getInstance();

	render = (calendar.get(Calendar.MONTH) == Calendar.DECEMBER && calendar.get(Calendar.DAY_OF_MONTH) >= 15) || (calendar.get(Calendar.MONTH) == Calendar.JANUARY && calendar.get(
			Calendar.DAY_OF_MONTH) <= 15);
}
 
源代码18 项目: TabletClock   文件: Moon.java
public static MoonPhases get(Date when) {
	Calendar cal = Calendar.getInstance();
	cal.setTime(when);
	int y = cal.get(Calendar.YEAR);
	int m = cal.get(Calendar.MONTH) + (12 - Calendar.DECEMBER); //+1 because january is 0
	int d = cal.get(Calendar.DAY_OF_MONTH);

	int yy = y - (12 - m) / 10;
	int mm = m + 9;
	if (mm >= 12) {
		mm = mm - 12;
	}
	int k1 = (int) (365.25 * (yy + 4712));
	int k2 = (int) (30.6001 * mm + 0.5);
	int k3 = (int) (((yy / 100) + 49) * 0.75) - 38;
	// 'j' for dates in Julian calendar:
	int j = k1 + k2 + d + 59;
	if (j > 2299160) {
		// For Gregorian calendar:
		j = j - k3; // 'j' is the Julian date at 12h UT (Universal Time)
	}
	double t = (j - 2451550.1) / 29.530588853;
	double phase = t - Math.floor(t);
	double age = phase * 29.53;

	if (age < 1.84566) {
		return MoonPhases.MOON_NEW;
	} else if (age < 5.53699) {
		return MoonPhases.MOON_EVENING_CRESCENT;
	} else if (age < 9.22831) {
		return MoonPhases.MOON_FIRST_QUARTER;
	} else if (age < 12.91963) {
		return MoonPhases.MOON_WAXING_GIBBOUS;
	} else if (age < 16.61096) {
		return MoonPhases.MOON_FULL;
	} else if (age < 20.30228) {
		return MoonPhases.MOON_WANING_GIBBOUS;
	} else if (age < 23.99361) {
		return MoonPhases.MOON_LAST_QUARTER;
	} else if (age < 27.68493) {
		return MoonPhases.MOON_MORNING_CRESCENT;
	} else {
		return MoonPhases.MOON_NEW;
	}
}
 
源代码19 项目: Birdays   文件: AllFragment.java
private Separator getSeparator(Person person) {
    Separator separator = null;
    switch (person.getMonth()) {
        case Calendar.JANUARY:
            if (!adapter.containsSeparatorJanuary) {
                adapter.containsSeparatorJanuary = true;
                separator = new Separator(Separator.TYPE_JANUARY);
            }
            break;
        case Calendar.FEBRUARY:
            if (!adapter.containsSeparatorFebruary) {
                adapter.containsSeparatorFebruary = true;
                separator = new Separator(Separator.TYPE_FEBRUARY);
            }
            break;
        case Calendar.MARCH:
            if (!adapter.containsSeparatorMarch) {
                adapter.containsSeparatorMarch = true;
                separator = new Separator(Separator.TYPE_MARCH);
            }
            break;
        case Calendar.APRIL:
            if (!adapter.containsSeparatorApril) {
                adapter.containsSeparatorApril = true;
                separator = new Separator(Separator.TYPE_APRIL);
            }
            break;
        case Calendar.MAY:
            if (!adapter.containsSeparatorMay) {
                adapter.containsSeparatorMay = true;
                separator = new Separator(Separator.TYPE_MAY);
            }
            break;
        case Calendar.JUNE:
            if (!adapter.containsSeparatorJune) {
                adapter.containsSeparatorJune = true;
                separator = new Separator(Separator.TYPE_JUNE);
            }
            break;
        case Calendar.JULY:
            if (!adapter.containsSeparatorJuly) {
                adapter.containsSeparatorJuly = true;
                separator = new Separator(Separator.TYPE_JULY);
            }
            break;
        case Calendar.AUGUST:
            if (!adapter.containsSeparatorAugust) {
                adapter.containsSeparatorAugust = true;
                separator = new Separator(Separator.TYPE_AUGUST);
            }
            break;
        case Calendar.SEPTEMBER:
            if (!adapter.containsSeparatorSeptember) {
                adapter.containsSeparatorSeptember = true;
                separator = new Separator(Separator.TYPE_SEPTEMBER);
            }
            break;
        case Calendar.OCTOBER:
            if (!adapter.containsSeparatorOctober) {
                adapter.containsSeparatorOctober = true;
                separator = new Separator(Separator.TYPE_OCTOBER);
            }
            break;
        case Calendar.NOVEMBER:
            if (!adapter.containsSeparatorNovember) {
                adapter.containsSeparatorNovember = true;
                separator = new Separator(Separator.TYPE_NOVEMBER);
            }
            break;
        case Calendar.DECEMBER:
            if (!adapter.containsSeparatorDecember) {
                adapter.containsSeparatorDecember = true;
                separator = new Separator(Separator.TYPE_DECEMBER);
            }
            break;
    }
    return separator;
}
 
源代码20 项目: openbd-core   文件: monthConverter.java
/**
 * takes a month and returns the index of it - JAN => 1, FEB => 2...
 * assumes byte[] is in lower case
 * returns -1 if an invalid month.
 */
 
public static int convertMonthToInt(char[] month){
  
  switch (month[0]){

    case 'j':
      if (equivalent(month, "january")){
        return Calendar.JANUARY;
      }
      else if (equivalent(month, "june")){
        return Calendar.JUNE;
      }
      else if (equivalent(month, "july")){
        return Calendar.JULY;
      }
      else
        return -1;
    
    case 'M':
    case 'm':
      if (equivalent(month, "may")){
        return Calendar.MAY;
      }
      else if (equivalent(month, "march")){
        return Calendar.MARCH;
      }
      else
        return -1;
    
    case 'A':
    case 'a':
      if (equivalent(month, "april")){
        return Calendar.APRIL;
      }
      else if (equivalent(month, "august")){
        return Calendar.AUGUST;
      }
      else
        return -1;
    
    case 'F':
    case 'f':
      if (equivalent(month, "february")){
        return Calendar.FEBRUARY;
      }
      else
        return -1;
        
    case 'D':
    case 'd':
      if (equivalent(month, "december")){
        return Calendar.DECEMBER;
      }
      else
        return -1;
        
    case 'S':
    case 's':
      if (equivalent(month, "september")){
        return Calendar.SEPTEMBER;
      }
      else
        return -1;
        
    case 'O':
    case 'o':
      if (equivalent(month, "october")){
        return Calendar.OCTOBER;
      }
      else
        return -1;
    
    case 'N':
    case 'n':
      if (equivalent(month, "november")){
        return Calendar.NOVEMBER;
      }
      else 
        return -1;
    
    default:
      return -1;
  }//switch
  
}