Java Code Examples for org.joda.time.DateMidnight#plusDays()

The following examples show how to use org.joda.time.DateMidnight#plusDays() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestGJChronology.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void testMaximumValue() {
    DateMidnight dt = new DateMidnight(1570, 1, 1, GJChronology.getInstance());
    while (dt.getYear() < 1590) {
        dt = dt.plusDays(1);
        YearMonthDay ymd = dt.toYearMonthDay();
        assertEquals(dt.year().getMaximumValue(), ymd.year().getMaximumValue());
        assertEquals(dt.monthOfYear().getMaximumValue(), ymd.monthOfYear().getMaximumValue());
        assertEquals(dt.dayOfMonth().getMaximumValue(), ymd.dayOfMonth().getMaximumValue());
    }
}
 
Example 2
Source File: TestISOChronology.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void testMaximumValue() {
    DateMidnight dt = new DateMidnight(1570, 1, 1);
    while (dt.getYear() < 1590) {
        dt = dt.plusDays(1);
        YearMonthDay ymd = dt.toYearMonthDay();
        assertEquals(dt.year().getMaximumValue(), ymd.year().getMaximumValue());
        assertEquals(dt.monthOfYear().getMaximumValue(), ymd.monthOfYear().getMaximumValue());
        assertEquals(dt.dayOfMonth().getMaximumValue(), ymd.dayOfMonth().getMaximumValue());
    }
}
 
Example 3
Source File: TestGJChronology.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void testMaximumValue() {
    DateMidnight dt = new DateMidnight(1570, 1, 1, GJChronology.getInstance());
    while (dt.getYear() < 1590) {
        dt = dt.plusDays(1);
        YearMonthDay ymd = dt.toYearMonthDay();
        assertEquals(dt.year().getMaximumValue(), ymd.year().getMaximumValue());
        assertEquals(dt.monthOfYear().getMaximumValue(), ymd.monthOfYear().getMaximumValue());
        assertEquals(dt.dayOfMonth().getMaximumValue(), ymd.dayOfMonth().getMaximumValue());
    }
}
 
Example 4
Source File: TestISOChronology.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void testMaximumValue() {
    DateMidnight dt = new DateMidnight(1570, 1, 1);
    while (dt.getYear() < 1590) {
        dt = dt.plusDays(1);
        YearMonthDay ymd = dt.toYearMonthDay();
        assertEquals(dt.year().getMaximumValue(), ymd.year().getMaximumValue());
        assertEquals(dt.monthOfYear().getMaximumValue(), ymd.monthOfYear().getMaximumValue());
        assertEquals(dt.dayOfMonth().getMaximumValue(), ymd.dayOfMonth().getMaximumValue());
    }
}
 
Example 5
Source File: HolidayEventsProvider.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @see org.projectforge.web.calendar.MyFullCalendarEventsProvider#buildEvents(org.joda.time.DateTime, org.joda.time.DateTime)
 */
@Override
protected void buildEvents(final DateTime start, final DateTime end)
{
  DateMidnight day = new DateMidnight(start);
  int idCounter = 0;
  int paranoiaCounter = 0;
  do {
    if (++paranoiaCounter > 4000) {
      log.error("Paranoia counter exceeded! Dear developer, please have a look at the implementation of buildEvents.");
      break;
    }
    final DayHolder dh = new DayHolder(day.toDate());
    String backgroundColor, color, textColor;
    if (dh.isHoliday() == true) {
      if (dh.isWorkingDay() == true) {
        backgroundColor = "#FFF0F0";
        color = "#EEEEEE";
        textColor = "#222222";
      } else {
        backgroundColor = "#f9dfde";
        color = "#EEEEEE";
        textColor = "#FF2222";
      }
    } else {
      day = day.plusDays(1);
      continue;
    }

    final Event event = new Event().setAllDay(true);
    final String id = "h-" + (++idCounter);
    event.setId(id);
    event.setStart(day.toDateTime());
    String title;
    final String holidayInfo = dh.getHolidayInfo();
    if (holidayInfo != null && holidayInfo.startsWith("calendar.holiday.") == true) {
      title = PFUserContext.getLocalizedString(holidayInfo);
    } else {
      title = holidayInfo;
    }
    event.setTitle(title);
    event.setBackgroundColor(backgroundColor);
    event.setColor(color);
    event.setTextColor(textColor);
    events.put(id, event);
    day = day.plusDays(1);
  } while (day.isAfter(end) == false);
}