/** * Check if the given dates are in the current year. * * @param start to be checked if in the current year * @param end to be checked if in the current year * * @return {@code true} if both dates are in the current year, else {@code false} */ boolean startAndEndDatesAreInCurrentYear(DateMidnight start, DateMidnight end) { int currentYear = DateMidnight.now().getYear(); return start.getYear() == currentYear && end.getYear() == currentYear; }
public int currentYear() { return now().getYear(); } }
AccountForm() { this(DateMidnight.now().getYear()); }
public int getYear() { return new DateTime(this.validFrom).toDateMidnight().getYear(); }
@PreAuthorize(SecurityRules.IS_OFFICE) @RequestMapping(value = "/sicknote/statistics", method = RequestMethod.GET) public String sickNotesStatistics(@RequestParam(value = "year", required = false) Integer requestedYear, Model model) { Integer year = requestedYear == null ? DateMidnight.now().getYear() : requestedYear; SickNoteStatistics statistics = statisticsService.createStatistics(year); model.addAttribute("statistics", statistics); return "sicknote/sick_notes_statistics"; } }
public CalendarWeek() { DateMidnight now = new DateMidnight(); this.year = now.getYear(); this.week = now.getWeekOfWeekyear(); }
@PreAuthorize(SecurityRules.IS_OFFICE) @RequestMapping(value = "/staff/{personId}/account", method = RequestMethod.GET) public String editAccount(@PathVariable("personId") Integer personId, @RequestParam(value = ControllerConstants.YEAR_ATTRIBUTE, required = false) Integer year, Model model) throws UnknownPersonException { Person person = personService.getPersonByID(personId).orElseThrow(() -> new UnknownPersonException(personId)); int yearOfHolidaysAccount = year != null ? year : DateMidnight.now().getYear(); AccountForm accountForm = new AccountForm(yearOfHolidaysAccount, accountService.getHolidaysAccount( yearOfHolidaysAccount, person)); model.addAttribute("person", person); model.addAttribute("account", accountForm); model.addAttribute("year", yearOfHolidaysAccount); return "account/account_form"; }
public FilterPeriod() { int currentYear = DateMidnight.now().getYear(); this.startDate = DateUtil.getFirstDayOfYear(currentYear); this.endDate = DateUtil.getLastDayOfYear(currentYear); }
public JodaDateConverter() { this.userDateFormat = getPattern(); this.timeZone = ThreadLocalUserContext.getDateTimeZone(); this.currentYear = new DateMidnight(timeZone).getYear(); }
DateDimensionImpl(DateMidnight date, int quarter, String term) { if (quarter < 0 || quarter > 3) { throw new IllegalArgumentException( "Quarter must be between 0 and 3, it is: " + quarter); } this.dateMidnight = date; this.id = -1; this.date = this.dateMidnight.toLocalDate(); this.year = dateMidnight.getYear(); this.month = dateMidnight.getMonthOfYear(); this.day = dateMidnight.getDayOfMonth(); this.week = (dateMidnight.getWeekyear() * 100) + dateMidnight.getWeekOfWeekyear(); this.quarter = quarter; this.term = term; }
@Override public void sendSuccessfullyUpdatedAccountsNotification(List<Account> updatedAccounts) { Map<String, Object> model = new HashMap<>(); model.put("accounts", updatedAccounts); model.put("year", DateMidnight.now().getYear()); String text = mailBuilder.buildMailBody("updated_accounts", model); // send email to office for printing statistic mailSender.sendEmail(getMailSettings(), RecipientUtil.getMailAddresses( recipientService.getRecipientsWithNotificationType(MailNotification.NOTIFICATION_OFFICE)), getTranslation("subject.account.updatedRemainingDays"), text); // send email to manager to notify about update of accounts sendTechnicalNotification(getTranslation("subject.account.updatedRemainingDays"), text); }
private BigDecimal getVacationDays(Application application, WorkDaysService calendarService) { int yearOfStartDate = application.getStartDate().getYear(); int yearOfEndDate = application.getEndDate().getYear(); Assert.isTrue(yearOfStartDate == this.year || yearOfEndDate == this.year, "Either start date or end date must be in the given year."); DayLength dayLength = application.getDayLength(); Person person = application.getPerson(); if (yearOfStartDate != yearOfEndDate) { DateMidnight startDate = getStartDateForCalculation(application); DateMidnight endDate = getEndDateForCalculation(application); return calendarService.getWorkDays(dayLength, startDate, endDate, person); } return calendarService.getWorkDays(dayLength, application.getStartDate(), application.getEndDate(), person); }
private BigDecimal getVacationDays(Application application, int relevantYear) { int yearOfStartDate = application.getStartDate().getYear(); int yearOfEndDate = application.getEndDate().getYear(); DayLength dayLength = application.getDayLength(); Person person = application.getPerson(); if (yearOfStartDate != yearOfEndDate) { DateMidnight startDate = getStartDateForCalculation(application, relevantYear); DateMidnight endDate = getEndDateForCalculation(application, relevantYear); return calendarService.getWorkDays(dayLength, startDate, endDate, person); } return calendarService.getWorkDays(dayLength, application.getStartDate(), application.getEndDate(), person); }
void validatePeriod(AccountForm form, Errors errors) { DateMidnight holidaysAccountValidFrom = form.getHolidaysAccountValidFrom(); DateMidnight holidaysAccountValidTo = form.getHolidaysAccountValidTo(); validateDateNotNull(holidaysAccountValidFrom, "holidaysAccountValidFrom", errors); validateDateNotNull(holidaysAccountValidTo, "holidaysAccountValidTo", errors); if (holidaysAccountValidFrom != null && holidaysAccountValidTo != null) { boolean periodIsNotWithinOneYear = holidaysAccountValidFrom.getYear() != form.getHolidaysAccountYear() || holidaysAccountValidTo.getYear() != form.getHolidaysAccountYear(); boolean periodIsOnlyOneDay = holidaysAccountValidFrom.equals(holidaysAccountValidTo); boolean beginOfPeriodIsAfterEndOfPeriod = holidaysAccountValidFrom.isAfter(holidaysAccountValidTo); if (periodIsNotWithinOneYear || periodIsOnlyOneDay || beginOfPeriodIsAfterEndOfPeriod) { errors.reject(ERROR_PERIOD); } } }
AccountForm(int year, Optional<Account> holidaysAccountOptional) { if (holidaysAccountOptional.isPresent()) { Account holidaysAccount = holidaysAccountOptional.get(); this.holidaysAccountYear = holidaysAccount.getValidFrom().getYear(); this.holidaysAccountValidFrom = holidaysAccount.getValidFrom(); this.holidaysAccountValidTo = holidaysAccount.getValidTo(); this.annualVacationDays = holidaysAccount.getAnnualVacationDays(); this.actualVacationDays = holidaysAccount.getVacationDays(); this.remainingVacationDays = holidaysAccount.getRemainingVacationDays(); this.remainingVacationDaysNotExpiring = holidaysAccount.getRemainingVacationDaysNotExpiring(); this.comment = holidaysAccount.getComment(); } else { this.holidaysAccountYear = year; this.holidaysAccountValidFrom = DateUtil.getFirstDayOfYear(year); this.holidaysAccountValidTo = DateUtil.getLastDayOfYear(year); } }
private void test(final TimeZone timeZone) { final PFUserDO user = new PFUserDO(); user.setTimeZone(timeZone); ThreadLocalUserContext.setUser(getUserGroupCache(), user); final JodaDateMidnightConverter converter = new JodaDateMidnightConverter(); final DateMidnight dateMidnight = (DateMidnight) converter.parse("1970-11-21"); assertEquals(1970, dateMidnight.getYear()); assertEquals(11, dateMidnight.getMonthOfYear()); assertEquals(21, dateMidnight.getDayOfMonth()); assertEquals("1970-11-21", converter.toString(dateMidnight)); } }