List of usage examples for org.joda.time MutableDateTime dayOfWeek
public Property dayOfWeek()
From source file:com.google.gerrit.server.config.ScheduleConfig.java
License:Apache License
private static long initialDelay(Config rc, String section, String subsection, String keyStartTime, DateTime now, long interval) { long delay = MISSING_CONFIG; String start = rc.getString(section, subsection, keyStartTime); try {/*from w ww.ja v a 2 s. c om*/ if (start != null) { DateTimeFormatter formatter; MutableDateTime startTime = now.toMutableDateTime(); try { formatter = ISODateTimeFormat.hourMinute(); LocalTime firstStartTime = formatter.parseLocalTime(start); startTime.hourOfDay().set(firstStartTime.getHourOfDay()); startTime.minuteOfHour().set(firstStartTime.getMinuteOfHour()); } catch (IllegalArgumentException e1) { formatter = DateTimeFormat.forPattern("E HH:mm").withLocale(Locale.US); LocalDateTime firstStartDateTime = formatter.parseLocalDateTime(start); startTime.dayOfWeek().set(firstStartDateTime.getDayOfWeek()); startTime.hourOfDay().set(firstStartDateTime.getHourOfDay()); startTime.minuteOfHour().set(firstStartDateTime.getMinuteOfHour()); } startTime.secondOfMinute().set(0); startTime.millisOfSecond().set(0); long s = startTime.getMillis(); long n = now.getMillis(); delay = (s - n) % interval; if (delay <= 0) { delay += interval; } } else { log.info(MessageFormat.format("{0} schedule parameter \"{0}.{1}\" is not configured", section, keyStartTime)); } } catch (IllegalArgumentException e2) { log.error(MessageFormat.format("Invalid {0} schedule parameter \"{0}.{1}\"", section, keyStartTime), e2); delay = INVALID_CONFIG; } return delay; }
From source file:com.tmathmeyer.sentinel.ui.views.month.MonthCalendar.java
License:Open Source License
/** * /* w ww . j av a 2 s . c o m*/ * @param fom the mutable date time */ public void generateHeaders(MutableDateTime fom) { // Set up label for month title monthLabel.setHorizontalAlignment(JLabel.CENTER); monthLabel.setFont(new java.awt.Font("DejaVu Sans", Font.BOLD, 25)); // Set up the container title panel (only holds monthLabel for now) calendarTitlePanel.setLayout(new BorderLayout()); calendarTitlePanel.add(monthLabel, BorderLayout.CENTER); // layout code mainCalendarView.setBackground(Colors.TABLE_BACKGROUND); mainCalendarView.setLayout(new BorderLayout()); top.setLayout(new GridLayout(1, 7)); mainCalendarView.add(top, BorderLayout.NORTH); mainCalendarView.add(inside, BorderLayout.CENTER); this.add(mainCalendarView, BorderLayout.CENTER); this.add(calendarTitlePanel, BorderLayout.NORTH); // end layout code fom.setDayOfMonth(1); fom.setMillisOfDay(0); int first = (fom.getDayOfWeek() % 7); fom.addDays(-first); // generate days on top for (int i = 0; i < 7; i++) { JLabel jl = new JLabel(fom.dayOfWeek().getAsText()); jl.setHorizontalAlignment(SwingConstants.CENTER); fom.addDays(1); top.add(jl); } }
From source file:com.xpn.xwiki.criteria.impl.PeriodFactory.java
License:Open Source License
private static MutableDateTime toWeekStart(MutableDateTime mdt) { mdt.setDayOfWeek(mdt.dayOfWeek().getMinimumValue()); return toDayStart(mdt); }
From source file:com.xpn.xwiki.criteria.impl.PeriodFactory.java
License:Open Source License
private static MutableDateTime toWeekEnd(MutableDateTime mdt) { mdt.setDayOfWeek(mdt.dayOfWeek().getMaximumValue()); return toDayEnd(mdt); }