List of usage examples for org.joda.time DateTimeConstants MARCH
int MARCH
To view the source code for org.joda.time DateTimeConstants MARCH.
Click Source Link
From source file:com.axelor.apps.base.service.scheduler.SchedulerService.java
License:Open Source License
/** * Mthode qui dtermine la prochaine date d'xcution d'un planificateur pour un rythme annuel * * @param scheduler//from w ww . ja v a2 s . c o m * Instance de planificateur * @param date * Derniere date d'xcution thorique * * @return LocalDate * Prochaine date d'xcution */ private LocalDate getAnnualComputeDate(Scheduler scheduler, LocalDate date) { int monthOfYear = 0; if (scheduler.getMonthAnnuallySelect().equals(IAdministration.JAN)) monthOfYear = DateTimeConstants.JANUARY; else if (scheduler.getMonthAnnuallySelect().equals(IAdministration.FEB)) monthOfYear = DateTimeConstants.FEBRUARY; else if (scheduler.getMonthAnnuallySelect().equals(IAdministration.MAR)) monthOfYear = DateTimeConstants.MARCH; else if (scheduler.getMonthAnnuallySelect().equals(IAdministration.APR)) monthOfYear = DateTimeConstants.APRIL; else if (scheduler.getMonthAnnuallySelect().equals(IAdministration.MAY)) monthOfYear = DateTimeConstants.MAY; else if (scheduler.getMonthAnnuallySelect().equals(IAdministration.JUN)) monthOfYear = DateTimeConstants.JUNE; else if (scheduler.getMonthAnnuallySelect().equals(IAdministration.JUL)) monthOfYear = DateTimeConstants.JULY; else if (scheduler.getMonthAnnuallySelect().equals(IAdministration.AUG)) monthOfYear = DateTimeConstants.AUGUST; else if (scheduler.getMonthAnnuallySelect().equals(IAdministration.SEP)) monthOfYear = DateTimeConstants.SEPTEMBER; else if (scheduler.getMonthAnnuallySelect().equals(IAdministration.OCT)) monthOfYear = DateTimeConstants.OCTOBER; else if (scheduler.getMonthAnnuallySelect().equals(IAdministration.NOV)) monthOfYear = DateTimeConstants.NOVEMBER; else if (scheduler.getMonthAnnuallySelect().equals(IAdministration.DEC)) monthOfYear = DateTimeConstants.DECEMBER; if (monthOfYear != 0) { int start = date.plusWeeks(scheduler.getWeekWeekly()).dayOfMonth().getMinimumValue(); int end = date.plusWeeks(scheduler.getWeekWeekly()).dayOfMonth().getMaximumValue(); if (start <= scheduler.getDayAnnually() && scheduler.getDayAnnually() <= end) return date.plusYears(scheduler.getYearAnnually()).withMonthOfYear(monthOfYear) .withDayOfMonth(scheduler.getDayAnnually()); else if (scheduler.getDayMonthly() < start) return date.plusYears(scheduler.getYearAnnually()).withMonthOfYear(monthOfYear).dayOfMonth() .withMinimumValue(); else if (scheduler.getDayMonthly() > end) return date.plusYears(scheduler.getYearAnnually()).withMonthOfYear(monthOfYear).dayOfMonth() .withMaximumValue(); } return null; }
From source file:com.fourmob.datetimepicker.Utils.java
License:Open Source License
public static int getDaysInMonth(final int month, final int year) { switch (month) { default:// w w w. j av a2s . c o m throw new IllegalArgumentException("Invalid Month"); case DateTimeConstants.JANUARY: case DateTimeConstants.MARCH: case DateTimeConstants.MAY: case DateTimeConstants.JULY: case DateTimeConstants.AUGUST: case DateTimeConstants.OCTOBER: case DateTimeConstants.DECEMBER: return 31; case DateTimeConstants.APRIL: case DateTimeConstants.JUNE: case DateTimeConstants.SEPTEMBER: case DateTimeConstants.NOVEMBER: return 30; case DateTimeConstants.FEBRUARY: if ((year % 4) == 0) { return 29; } return 28; } }
From source file:com.helger.datetime.holiday.mgr.XMLUtil.java
License:Apache License
/** * Returns the {@link DateTimeConstants} value for the given month. * /*from www.ja va2 s . c o m*/ * @param eMonth * Month of year to convert * @return {@link DateTimeConstants} value. */ @Nonnegative public static int getMonth(@Nonnull final Month eMonth) { switch (eMonth) { case JANUARY: return DateTimeConstants.JANUARY; case FEBRUARY: return DateTimeConstants.FEBRUARY; case MARCH: return DateTimeConstants.MARCH; case APRIL: return DateTimeConstants.APRIL; case MAY: return DateTimeConstants.MAY; case JUNE: return DateTimeConstants.JUNE; case JULY: return DateTimeConstants.JULY; case AUGUST: return DateTimeConstants.AUGUST; case SEPTEMBER: return DateTimeConstants.SEPTEMBER; case OCTOBER: return DateTimeConstants.OCTOBER; case NOVEMBER: return DateTimeConstants.NOVEMBER; case DECEMBER: return DateTimeConstants.DECEMBER; default: throw new IllegalArgumentException("Unknown month " + eMonth); } }
From source file:com.helger.datetime.holiday.parser.impl.IslamicHolidayParser.java
License:Apache License
public void parse(final int nYear, final HolidayMap aHolidayMap, final Holidays aConfig) { for (final IslamicHoliday aIslamicHoliday : aConfig.getIslamicHoliday()) { if (!isValid(aIslamicHoliday, nYear)) continue; Set<LocalDate> aIslamicHolidays; switch (aIslamicHoliday.getType()) { case NEWYEAR: aIslamicHolidays = CalendarUtil.getIslamicHolidaysInGregorianYear(nYear, DateTimeConstants.JANUARY, 1);//from w ww .j av a 2 s . c o m break; case ASCHURA: aIslamicHolidays = CalendarUtil.getIslamicHolidaysInGregorianYear(nYear, DateTimeConstants.JANUARY, 10); break; case ID_AL_FITR: aIslamicHolidays = CalendarUtil.getIslamicHolidaysInGregorianYear(nYear, DateTimeConstants.OCTOBER, 1); break; case ID_UL_ADHA: aIslamicHolidays = CalendarUtil.getIslamicHolidaysInGregorianYear(nYear, DateTimeConstants.DECEMBER, 10); break; case LAILAT_AL_BARAT: aIslamicHolidays = CalendarUtil.getIslamicHolidaysInGregorianYear(nYear, DateTimeConstants.AUGUST, 15); break; case LAILAT_AL_MIRAJ: aIslamicHolidays = CalendarUtil.getIslamicHolidaysInGregorianYear(nYear, DateTimeConstants.JULY, 27); break; case LAILAT_AL_QADR: aIslamicHolidays = CalendarUtil.getIslamicHolidaysInGregorianYear(nYear, DateTimeConstants.SEPTEMBER, 27); break; case MAWLID_AN_NABI: aIslamicHolidays = CalendarUtil.getIslamicHolidaysInGregorianYear(nYear, DateTimeConstants.MARCH, 12); break; case RAMADAN: aIslamicHolidays = CalendarUtil.getIslamicHolidaysInGregorianYear(nYear, DateTimeConstants.SEPTEMBER, 1); break; default: throw new IllegalArgumentException("Unknown islamic holiday " + aIslamicHoliday.getType()); } final IHolidayType aType = XMLUtil.getType(aIslamicHoliday.getLocalizedType()); final String sPropertiesKey = "islamic." + aIslamicHoliday.getType().name(); for (final LocalDate aDate : aIslamicHolidays) aHolidayMap.add(aDate, new ResourceBundleHoliday(aType, sPropertiesKey)); } }
From source file:com.helger.datetime.holiday.parser.impl.RelativeToEasterSundayParser.java
License:Apache License
/** * Returns the easter Sunday within the julian chronology. * /*from w w w. j ava2 s .c o m*/ * @param nYear * The year to retrieve Julian Easter Sunday date * @return julian easter Sunday */ public static LocalDate getJulianEasterSunday(final int nYear) { int a, b, c, d, e; int x, nMonth, nDay; a = nYear % 4; b = nYear % 7; c = nYear % 19; d = (19 * c + 15) % 30; e = (2 * a + 4 * b - d + 34) % 7; x = d + e + 114; nMonth = x / 31; nDay = (x % 31) + 1; return new LocalDate(nYear, (nMonth == 3 ? DateTimeConstants.MARCH : DateTimeConstants.APRIL), nDay, JulianChronology.getInstance()); }
From source file:com.helger.datetime.holiday.parser.impl.RelativeToEasterSundayParser.java
License:Apache License
/** * Returns the easter Sunday within the gregorian chronology. * /* ww w. j a va2 s .c o m*/ * @param nYear * The year to retrieve Gregorian Easter Sunday date * @return gregorian easter Sunday. */ public static LocalDate getGregorianEasterSunday(final int nYear) { int a, b, c, d, e, f, g, h, i, j, k, l; int x, nMonth, nDay; a = nYear % 19; b = nYear / 100; c = nYear % 100; d = b / 4; e = b % 4; f = (b + 8) / 25; g = (b - f + 1) / 3; h = (19 * a + b - d - g + 15) % 30; i = c / 4; j = c % 4; k = (32 + 2 * e + 2 * i - h - j) % 7; l = (a + 11 * h + 22 * k) / 451; x = h + k - 7 * l + 114; nMonth = x / 31; nDay = (x % 31) + 1; return new LocalDate(nYear, (nMonth == 3 ? DateTimeConstants.MARCH : DateTimeConstants.APRIL), nDay, GregorianChronology.getInstance(PDTConfig.getDefaultDateTimeZone())); }
From source file:com.jjlharrison.jollyday.parser.impl.IslamicHolidayParser.java
License:Apache License
/** {@inheritDoc} */ public void parse(int year, Set<Holiday> holidays, final Holidays config) { for (IslamicHoliday i : config.getIslamicHoliday()) { if (!isValid(i, year)) { continue; }//w ww .j av a 2s. c o m Set<LocalDate> islamicHolidays = null; switch (i.getType()) { case NEWYEAR: islamicHolidays = calendarUtil.getIslamicHolidaysInGregorianYear(year, DateTimeConstants.JANUARY, 1); break; case ASCHURA: islamicHolidays = calendarUtil.getIslamicHolidaysInGregorianYear(year, DateTimeConstants.JANUARY, 10); break; case ID_AL_FITR: islamicHolidays = calendarUtil.getIslamicHolidaysInGregorianYear(year, DateTimeConstants.OCTOBER, 1); break; case ID_UL_ADHA: islamicHolidays = calendarUtil.getIslamicHolidaysInGregorianYear(year, DateTimeConstants.DECEMBER, 10); break; case LAILAT_AL_BARAT: islamicHolidays = calendarUtil.getIslamicHolidaysInGregorianYear(year, DateTimeConstants.AUGUST, 15); break; case LAILAT_AL_MIRAJ: islamicHolidays = calendarUtil.getIslamicHolidaysInGregorianYear(year, DateTimeConstants.JULY, 27); break; case LAILAT_AL_QADR: islamicHolidays = calendarUtil.getIslamicHolidaysInGregorianYear(year, DateTimeConstants.SEPTEMBER, 27); break; case MAWLID_AN_NABI: islamicHolidays = calendarUtil.getIslamicHolidaysInGregorianYear(year, DateTimeConstants.MARCH, 12); break; case RAMADAN: islamicHolidays = calendarUtil.getIslamicHolidaysInGregorianYear(year, DateTimeConstants.SEPTEMBER, 1); break; default: throw new IllegalArgumentException("Unknown islamic holiday " + i.getType()); } String propertiesKey = PREFIX_PROPERTY_ISLAMIC + i.getType().name(); HolidayType type = xmlUtil.getType(i.getLocalizedType()); for (LocalDate d : islamicHolidays) { holidays.add(new Holiday(d, propertiesKey, type)); } } }
From source file:com.jjlharrison.jollyday.util.CalendarUtil.java
License:Apache License
/** * Returns the easter sunday within the julian chronology. * * @param year//ww w . j a v a2s. c om * a int. * @return julian easter sunday */ public LocalDate getJulianEasterSunday(int year) { int a, b, c, d, e; int x, month, day; a = year % 4; b = year % 7; c = year % 19; d = (19 * c + 15) % 30; e = (2 * a + 4 * b - d + 34) % 7; x = d + e + 114; month = x / 31; day = (x % 31) + 1; LocalDate julianEasterDate = create(year, (month == 3 ? DateTimeConstants.MARCH : DateTimeConstants.APRIL), day, JulianChronology.getInstanceUTC()); return convertToISODate(julianEasterDate); }
From source file:com.jjlharrison.jollyday.util.CalendarUtil.java
License:Apache License
/** * Returns the easter sunday within the gregorian chronology. * * @param year// w ww . ja v a2 s .c o m * a int. * @return gregorian easter sunday. */ public LocalDate getGregorianEasterSunday(int year) { int a, b, c, d, e, f, g, h, i, j, k, l; int x, month, day; a = year % 19; b = year / 100; c = year % 100; d = b / 4; e = b % 4; f = (b + 8) / 25; g = (b - f + 1) / 3; h = (19 * a + b - d - g + 15) % 30; i = c / 4; j = c % 4; k = (32 + 2 * e + 2 * i - h - j) % 7; l = (a + 11 * h + 22 * k) / 451; x = h + k - 7 * l + 114; month = x / 31; day = (x % 31) + 1; return create(year, (month == 3 ? DateTimeConstants.MARCH : DateTimeConstants.APRIL), day); }
From source file:com.jjlharrison.jollyday.util.XMLUtil.java
License:Apache License
/** * Returns the <code>DateTimeConstants</code> value for the given month. * * @param month/* ww w . ja v a2s . co m*/ * a {@link com.jjlharrison.config.Month} object. * @return DateTimeConstants value. */ public int getMonth(Month month) { switch (month) { case JANUARY: return DateTimeConstants.JANUARY; case FEBRUARY: return DateTimeConstants.FEBRUARY; case MARCH: return DateTimeConstants.MARCH; case APRIL: return DateTimeConstants.APRIL; case MAY: return DateTimeConstants.MAY; case JUNE: return DateTimeConstants.JUNE; case JULY: return DateTimeConstants.JULY; case AUGUST: return DateTimeConstants.AUGUST; case SEPTEMBER: return DateTimeConstants.SEPTEMBER; case OCTOBER: return DateTimeConstants.OCTOBER; case NOVEMBER: return DateTimeConstants.NOVEMBER; case DECEMBER: return DateTimeConstants.DECEMBER; default: throw new IllegalArgumentException("Unknown month " + month); } }