List of usage examples for java.util Calendar DECEMBER
int DECEMBER
To view the source code for java.util Calendar DECEMBER.
Click Source Link
From source file:com.appeaser.sublimepickerlibrary.datepicker.SimpleMonthView.java
private static boolean isValidMonth(int month) { return month >= Calendar.JANUARY && month <= Calendar.DECEMBER; }
From source file:com.stratelia.webactiv.util.DateUtil.java
/** * Compute the date of the last day in the year of the specified date. * @param date the specified date.// www. j a va2 s . co m * @return a date for the last day of the year of the specified date. */ public static Date getEndDateOfYear(Date date) { Calendar calendar = getInstance(); calendar.setTime(date); calendar.set(MONTH, Calendar.DECEMBER); calendar.set(HOUR_OF_DAY, 23); calendar.set(MINUTE, 59); calendar.set(SECOND, 59); calendar.set(MILLISECOND, 999); calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1, 1); calendar.add(Calendar.DATE, -1); return calendar.getTime(); }
From source file:com.alkacon.opencms.calendar.CmsSerialDateWidget.java
/** * Returns the HTML for a select box for choosing the month.<p> * //from ww w . j a va2 s.c om * @param name the name of the select box * @param parameters optional additional parameters * @param messages localized messages for localizing the options * @param selectedIndex the selected index of the month * @return the HTML for a select box for choosing the month */ protected String buildSelectMonth(String name, String parameters, CmsMessages messages, int selectedIndex) { SimpleDateFormat df = new SimpleDateFormat("MMMM", messages.getLocale()); Calendar cal = new GregorianCalendar(messages.getLocale()); cal.set(2000, Calendar.JANUARY, 1); List options = new ArrayList(12); List values = new ArrayList(12); for (int i = 0; i <= Calendar.DECEMBER; i++) { // iterate the months values.add(String.valueOf(cal.get(Calendar.MONTH))); options.add(df.format(cal.getTime())); cal.add(Calendar.MONTH, 1); } // add the name to the parameters if (CmsStringUtil.isNotEmpty(parameters)) { parameters += " "; } parameters += "name=\"" + name + "\""; return CmsWorkplace.buildSelect(parameters, options, values, selectedIndex, true); }
From source file:cn.mljia.common.notify.utils.DateUtils.java
/** * ?/*www . j a v a2 s . c om*/ * * @param date * @return */ public static Date[] getSeasonDate(Date date) { Date[] season = new Date[3]; Calendar c = Calendar.getInstance(); c.setTime(date); int nSeason = getSeason(date); if (nSeason == 1) {// c.set(Calendar.MONTH, Calendar.JANUARY); season[0] = c.getTime(); c.set(Calendar.MONTH, Calendar.FEBRUARY); season[1] = c.getTime(); c.set(Calendar.MONTH, Calendar.MARCH); season[2] = c.getTime(); } else if (nSeason == 2) {// c.set(Calendar.MONTH, Calendar.APRIL); season[0] = c.getTime(); c.set(Calendar.MONTH, Calendar.MAY); season[1] = c.getTime(); c.set(Calendar.MONTH, Calendar.JUNE); season[2] = c.getTime(); } else if (nSeason == 3) {// c.set(Calendar.MONTH, Calendar.JULY); season[0] = c.getTime(); c.set(Calendar.MONTH, Calendar.AUGUST); season[1] = c.getTime(); c.set(Calendar.MONTH, Calendar.SEPTEMBER); season[2] = c.getTime(); } else if (nSeason == 4) {// c.set(Calendar.MONTH, Calendar.OCTOBER); season[0] = c.getTime(); c.set(Calendar.MONTH, Calendar.NOVEMBER); season[1] = c.getTime(); c.set(Calendar.MONTH, Calendar.DECEMBER); season[2] = c.getTime(); } return season; }
From source file:cn.mljia.common.notify.utils.DateUtils.java
/** * // ww w . j a v a 2s .co m * 1 2 3 4 * * @param date * @return */ public static int getSeason(Date date) { int season = 0; Calendar c = Calendar.getInstance(); c.setTime(date); int month = c.get(Calendar.MONTH); switch (month) { case Calendar.JANUARY: case Calendar.FEBRUARY: case Calendar.MARCH: season = 1; break; case Calendar.APRIL: case Calendar.MAY: case Calendar.JUNE: season = 2; break; case Calendar.JULY: case Calendar.AUGUST: case Calendar.SEPTEMBER: season = 3; break; case Calendar.OCTOBER: case Calendar.NOVEMBER: case Calendar.DECEMBER: season = 4; break; default: break; } return season; }
From source file:org.exoplatform.addon.pulse.service.ws.RestActivitiesStatistic.java
private ChartData buildPlfDownloadData(String maxColumn, String filter, Date fromDate) { int totalDataCoulumn = 5; try {//from ww w. j a v a2 s . c o m totalDataCoulumn = Integer.parseInt(maxColumn); } catch (Exception e) { //do nothing } if (filter.equalsIgnoreCase(FILTER_BY_DAY)) { List<String> listTitle = new ArrayList<String>(); List<Long> plfDownloadsData = new ArrayList<Long>(); for (int i = 0; i < totalDataCoulumn; i++) { Calendar calendar = Calendar.getInstance(); calendar.clear(); calendar.setTime(fromDate); calendar.add(Calendar.DATE, i); Date toDate = calendar.getTime(); String toDateStr = partString(toDate, "yyyy-MM-dd"); listTitle.add(partString(toDate, "dd-MM-yyyy")); String url = "http://sourceforge.net/projects/exo/files/stats/json?start_date=" + toDateStr + "&end_date=" + toDateStr; try { String returnValue = httpGet(url); plfDownloadsData.add(getTotalPlfDownloadDataFromJson(returnValue, toDate)); } catch (Exception e) { LOG.error(e.getMessage()); plfDownloadsData.add(0l); } } ChartData chartData = new ChartData(); chartData.setListTitle(listTitle); chartData.setPlfDownloadsData(plfDownloadsData); return chartData; } if (filter.equalsIgnoreCase(FILTER_BY_WEEK)) { List<String> listTitle = new ArrayList<String>(); List<Long> plfDownloadsData = new ArrayList<Long>(); String fromDateStr = partString(fromDate, "yyyy-MM-dd"); Calendar calendar = Calendar.getInstance(); calendar.clear(); calendar.setTime(fromDate); int fromWeek = calendar.get(Calendar.WEEK_OF_YEAR); int fromMonth = calendar.get(Calendar.MONTH); if (fromMonth == Calendar.DECEMBER && fromWeek == 1) fromWeek = 53; int fromYear = calendar.get(Calendar.YEAR); calendar.clear(); calendar.set(Calendar.WEEK_OF_YEAR, fromWeek); calendar.set(Calendar.YEAR, fromYear); Date beginWeekDate = calendar.getTime(); calendar.clear(); calendar.setTime(beginWeekDate); calendar.add(Calendar.DATE, 6); Date endWeekDate = calendar.getTime(); calendar.clear(); String toDateStr = partString(endWeekDate, "yyyy-MM-dd"); for (int i = 0; i < totalDataCoulumn; i++) { calendar.setTime(endWeekDate); listTitle.add("W" + calendar.get(Calendar.WEEK_OF_YEAR) + "-" + calendar.get(Calendar.YEAR)); String url = "http://sourceforge.net/projects/exo/files/stats/json?start_date=" + fromDateStr + "&end_date=" + toDateStr; try { String returnValue = httpGet(url); plfDownloadsData.add( getTotalPlfDownloadDataFromJson(returnValue, parseDate(fromDateStr, "yyyy-MM-dd"))); } catch (Exception e) { LOG.error(e.getMessage()); plfDownloadsData.add(0l); } calendar.clear(); fromDate = endWeekDate; calendar.setTime(fromDate); calendar.add(Calendar.DATE, 1); fromDate = calendar.getTime(); fromDateStr = partString(fromDate, "yyyy-MM-dd"); calendar.add(Calendar.DATE, 6); endWeekDate = calendar.getTime(); toDateStr = partString(endWeekDate, "yyyy-MM-dd"); calendar.clear(); } ChartData chartData = new ChartData(); chartData.setListTitle(listTitle); chartData.setPlfDownloadsData(plfDownloadsData); return chartData; } if (filter.equalsIgnoreCase(FILTER_BY_MONTH)) { List<String> listTitle = new ArrayList<String>(); List<Long> plfDownloadsData = new ArrayList<Long>(); String fromDateStr = partString(fromDate, "yyyy-MM-dd"); Calendar calendar = Calendar.getInstance(); calendar.clear(); calendar.setTime(fromDate); int fromMonth = calendar.get(Calendar.MONTH); int fromYear = calendar.get(Calendar.YEAR); //calendar.add(Calendar.MONTH, totalDataCoulumn); //int toYear = calendar.get(Calendar.YEAR); calendar.clear(); calendar.set(Calendar.MONTH, fromMonth); calendar.set(Calendar.YEAR, fromYear); Date beginMonthDate = calendar.getTime(); calendar.clear(); calendar.setTime(beginMonthDate); int dayOfMonth = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); calendar.add(Calendar.DATE, dayOfMonth - 1); Date endMonthDate = calendar.getTime(); calendar.clear(); String toDateStr = partString(endMonthDate, "yyyy-MM-dd"); for (int i = 0; i < totalDataCoulumn; i++) { calendar.setTime(endMonthDate); listTitle.add(partString(calendar.getTime(), "MMM") + "-" + calendar.get(Calendar.YEAR)); String url = "http://sourceforge.net/projects/exo/files/stats/json?start_date=" + fromDateStr + "&end_date=" + toDateStr; try { String returnValue = httpGet(url); plfDownloadsData.add( getTotalPlfDownloadDataFromJson(returnValue, parseDate(fromDateStr, "yyyy-MM-dd"))); } catch (Exception e) { plfDownloadsData.add(0l); } calendar.clear(); fromDate = endMonthDate; calendar.setTime(fromDate); calendar.add(Calendar.DATE, 1); fromDate = calendar.getTime(); fromDateStr = partString(fromDate, "yyyy-MM-dd"); dayOfMonth = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); calendar.add(Calendar.DATE, dayOfMonth - 1); endMonthDate = calendar.getTime(); toDateStr = partString(endMonthDate, "yyyy-MM-dd"); calendar.clear(); } ChartData chartData = new ChartData(); chartData.setListTitle(listTitle); chartData.setPlfDownloadsData(plfDownloadsData); return chartData; } return null; }
From source file:com.alkacon.opencms.calendar.CmsCalendarDisplay.java
/** * Returns all displayed days of the specified year with their corresponding entries as lists.<p> * /*from w w w . jav a 2s . c o m*/ * The key of the Map has to be a Date object.<p> * * The Map values are always lists of {@link CmsCalendarEntry} objects, if no entries are available for a specific day, * an empty List is returned.<p> * * @param year the year of the month to display * @return all displayed days of the specified day range with their corresponding entries as lists */ public Map getEntriesForYear(int year) { Calendar startDay = new GregorianCalendar(getJsp().getRequestContext().getLocale()); startDay.set(Calendar.YEAR, year); startDay.set(Calendar.MONTH, Calendar.JANUARY); startDay.set(Calendar.DAY_OF_MONTH, 1); Calendar endDay = (Calendar) startDay.clone(); endDay.set(Calendar.MONTH, Calendar.DECEMBER); endDay.set(Calendar.DAY_OF_MONTH, 31); return getEntriesForDays(startDay, endDay); }
From source file:org.kuali.kfs.module.endow.document.service.impl.CurrentTaxLotServiceImpl.java
/** * This method will check the current month and set the calendar to that month * /* w w w. j a va 2s . c o m*/ * @param month month to set the calendar, currentDate currentDate * @return calendar calendar is set to the month selected */ protected Calendar setCaledarWithMonth(String month, Date lastPaymentDate) { Calendar calendar = Calendar.getInstance(); calendar.setTime(lastPaymentDate); int calendarMonth = 1; if (EndowConstants.FrequencyMonths.JANUARY.equalsIgnoreCase(month)) { calendarMonth = Calendar.JANUARY; } else if (EndowConstants.FrequencyMonths.FEBRUARY.equalsIgnoreCase(month)) { calendarMonth = Calendar.FEBRUARY; } else if (EndowConstants.FrequencyMonths.MARCH.equalsIgnoreCase(month)) { calendarMonth = Calendar.MARCH; } else if (EndowConstants.FrequencyMonths.APRIL.equalsIgnoreCase(month)) { calendarMonth = Calendar.APRIL; } else if (EndowConstants.FrequencyMonths.MAY.equalsIgnoreCase(month)) { calendarMonth = Calendar.MAY; } else if (EndowConstants.FrequencyMonths.JUNE.equalsIgnoreCase(month)) { calendarMonth = Calendar.JUNE; } else if (EndowConstants.FrequencyMonths.JULY.equalsIgnoreCase(month)) { calendarMonth = Calendar.JULY; } else if (EndowConstants.FrequencyMonths.AUGUST.equalsIgnoreCase(month)) { calendarMonth = Calendar.AUGUST; } else if (EndowConstants.FrequencyMonths.SEPTEMBER.equalsIgnoreCase(month)) { calendarMonth = Calendar.SEPTEMBER; } else if (EndowConstants.FrequencyMonths.OCTOBER.equalsIgnoreCase(month)) { calendarMonth = Calendar.OCTOBER; } else if (EndowConstants.FrequencyMonths.NOVEMBER.equalsIgnoreCase(month)) { calendarMonth = Calendar.NOVEMBER; } else if (EndowConstants.FrequencyMonths.DECEMBER.equalsIgnoreCase(month)) { calendarMonth = Calendar.DECEMBER; } calendar.set(Calendar.MONTH, calendarMonth); return calendar; }
From source file:gov.nih.nci.firebird.selenium2.tests.profile.AssociatedOrganizationTabTest.java
private void checkForExpirationBeforeEffectiveDateError(final LabCertificatesDialog labCertificatesDialog) { Date today = new Date(); labCertificatesDialog.getHelper().setEffectiveDate(DateUtils.setMonths(today, Calendar.DECEMBER)); labCertificatesDialog.getHelper().setExpirationDate(DateUtils.setMonths(today, Calendar.OCTOBER)); ExpectedValidationFailure expectedValidationFailure = new ExpectedValidationFailure( "error.expiration.date.before.effective"); expectedValidationFailure.assertFailureOccurs(new FailingAction() { @Override/*from w ww.java 2s .co m*/ public void perform() { labCertificatesDialog.clickSave(); } }); }
From source file:com.bw.luzz.monkeyapplication.View.DateTimePicker.date.DatePickerDialog.java
@Override public Calendar getEndDate() { if (selectableDays != null) return selectableDays[selectableDays.length - 1]; if (mMaxDate != null) return mMaxDate; Calendar output = Calendar.getInstance(); output.set(Calendar.YEAR, mMaxYear); output.set(Calendar.DAY_OF_MONTH, 31); output.set(Calendar.MONTH, Calendar.DECEMBER); return output; }