Search in sources :

Example 61 with Calendar

use of java.util.Calendar in project head by mifos.

the class AccountBO method changeFirstInstallmentDateBy.

public void changeFirstInstallmentDateBy(final int numberOfDays) {
    Calendar currentDateCalendar = new GregorianCalendar();
    int year = currentDateCalendar.get(Calendar.YEAR);
    int month = currentDateCalendar.get(Calendar.MONTH);
    int day = currentDateCalendar.get(Calendar.DAY_OF_MONTH);
    currentDateCalendar = new GregorianCalendar(year, month, day + numberOfDays);
    changeActionDateOfFirstInstallment(currentDateCalendar, getAccountActionDates());
}
Also used : GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar)

Example 62 with Calendar

use of java.util.Calendar in project head by mifos.

the class HolidayServiceFacadeWebTierTest method isFutureRepaymentHoliday.

@Test
public void isFutureRepaymentHoliday() {
    Calendar dueDate = toCalendar("01-Nov-2010");
    when(holidayService.isFutureRepaymentHoliday(dueDate, officeId)).thenReturn(true);
    Assert.assertTrue(holidayServiceFacade.isFutureRepaymentHoliday(officeId, dueDate));
    verify(holidayService, times(1)).isFutureRepaymentHoliday(dueDate, officeId);
}
Also used : Calendar(java.util.Calendar) Test(org.junit.Test)

Example 63 with Calendar

use of java.util.Calendar in project head by mifos.

the class HolidayServiceTest method shouldGetTheSameDayIfAlreadyWorkingDay.

@Test
public void shouldGetTheSameDayIfAlreadyWorkingDay() {
    Calendar workingDay = toCalendar("01-Nov-2010");
    DateTime holidayAsDateTime = new DateTime(workingDay.getTime().getTime());
    String holidayAsString = holidayAsDateTime.toLocalDate().toString();
    when(fiscalCalendarRules.isWorkingDay(workingDay)).thenReturn(true);
    when(holidayDao.isHoliday(officeId, holidayAsString)).thenReturn(false);
    Calendar nextWorkingDay = holidayService.getNextWorkingDay(toCalendar("01-Nov-2010"), officeId);
    assertThat(nextWorkingDay, is(workingDay));
    verify(fiscalCalendarRules, times(1)).isWorkingDay(workingDay);
    verify(holidayDao).isHoliday(officeId, holidayAsString);
}
Also used : Calendar(java.util.Calendar) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 64 with Calendar

use of java.util.Calendar in project head by mifos.

the class HolidayServiceTest method shouldDetermineIfRegularHolidayIsNotWorkingDay.

@Test
public void shouldDetermineIfRegularHolidayIsNotWorkingDay() {
    Calendar holiday = toCalendar("01-Nov-2010");
    when(fiscalCalendarRules.isWorkingDay(holiday)).thenReturn(false);
    assertThat(holidayService.isWorkingDay(holiday, officeId), is(false));
    verify(fiscalCalendarRules, times(1)).isWorkingDay(holiday);
}
Also used : Calendar(java.util.Calendar) Test(org.junit.Test)

Example 65 with Calendar

use of java.util.Calendar in project head by mifos.

the class HolidayServiceTest method shouldGetNextWorkingDay.

@Test
public void shouldGetNextWorkingDay() {
    Calendar holiday1 = toCalendar("01-Nov-2010");
    when(fiscalCalendarRules.isWorkingDay(holiday1)).thenReturn(false);
    Calendar holiday2 = toCalendar("02-Nov-2010");
    DateTime holiday2AsDateTime = new DateTime(holiday2.getTime().getTime());
    String holiday2AsString = holiday2AsDateTime.toLocalDate().toString();
    when(fiscalCalendarRules.isWorkingDay(holiday2)).thenReturn(true);
    when(holidayDao.isHoliday(officeId, holiday2AsString)).thenReturn(true);
    Calendar holiday3 = toCalendar("03-Nov-2010");
    DateTime holiday3AsDateTime = new DateTime(holiday3.getTime().getTime());
    String holiday3AsString = holiday3AsDateTime.toLocalDate().toString();
    when(fiscalCalendarRules.isWorkingDay(holiday3)).thenReturn(true);
    when(holidayDao.isHoliday(officeId, holiday3AsString)).thenReturn(true);
    Calendar workingDay = toCalendar("04-Nov-2010");
    DateTime holidayAsDateTime = new DateTime(workingDay.getTime().getTime());
    String holidayAsString = holidayAsDateTime.toLocalDate().toString();
    when(fiscalCalendarRules.isWorkingDay(workingDay)).thenReturn(true);
    when(holidayDao.isHoliday(officeId, holidayAsString)).thenReturn(false);
    Calendar nextWorkingDay = holidayService.getNextWorkingDay(toCalendar("01-Nov-2010"), officeId);
    assertThat(nextWorkingDay.get(Calendar.DAY_OF_MONTH), is(4));
    assertThat(nextWorkingDay.get(Calendar.MONTH), is(10));
    assertThat(nextWorkingDay.get(Calendar.YEAR), is(2010));
    verify(fiscalCalendarRules, times(4)).isWorkingDay(Matchers.<Calendar>anyObject());
    verify(holidayDao, times(3)).isHoliday(Matchers.anyShort(), Matchers.anyString());
}
Also used : Calendar(java.util.Calendar) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Aggregations

Calendar (java.util.Calendar)9446 Date (java.util.Date)2436 GregorianCalendar (java.util.GregorianCalendar)2130 Test (org.junit.Test)1735 SimpleDateFormat (java.text.SimpleDateFormat)889 ArrayList (java.util.ArrayList)476 ParseException (java.text.ParseException)353 HashMap (java.util.HashMap)270 TimeZone (java.util.TimeZone)270 IOException (java.io.IOException)235 DateFormat (java.text.DateFormat)224 Timestamp (java.sql.Timestamp)194 List (java.util.List)187 File (java.io.File)167 Map (java.util.Map)149 BigDecimal (java.math.BigDecimal)134 Locale (java.util.Locale)134 Test (org.testng.annotations.Test)118 Identity (org.olat.core.id.Identity)112 Date (java.sql.Date)110