Example usage for java.util Calendar DECEMBER

List of usage examples for java.util Calendar DECEMBER

Introduction

In this page you can find the example usage for java.util Calendar DECEMBER.

Prototype

int DECEMBER

To view the source code for java.util Calendar DECEMBER.

Click Source Link

Document

Value of the #MONTH field indicating the twelfth month of the year in the Gregorian and Julian calendars.

Usage

From source file:org.techytax.util.DateHelper.java

public static FiscalPeriod getPeriodPreviousYear() {
    Calendar cal = new GregorianCalendar();
    cal.setTime(new Date());
    cal.add(Calendar.YEAR, -1);/* w  w w  .j av  a 2s  .  co m*/
    cal.set(Calendar.MONTH, Calendar.JANUARY);
    cal.set(Calendar.DAY_OF_MONTH, 1);
    Date beginDatum = cal.getTime();
    cal.set(Calendar.MONTH, Calendar.DECEMBER);
    cal.set(Calendar.DAY_OF_MONTH, 31);
    Date eindDatum = cal.getTime();
    return new FiscalPeriod(beginDatum, eindDatum);
}

From source file:org.pivotal.gemfire.cache.CacheRegionQueryUsingToDateTest.java

@Before
public void setupPeople() {
    Region<Long, Person> localPeople = gemfireCache.getRegion("/People");

    put(localPeople, createPerson("Jon", "Doe", createDate(1979, Calendar.MAY, 15)));
    put(localPeople, createPerson("Jane", "Doe", createDate(1981, Calendar.APRIL, 21)));
    put(localPeople, createPerson("Pie", "Doe", createDate(1997, Calendar.NOVEMBER, 22)));
    put(localPeople, createPerson("Cookie", "Doe", createDate(2008, Calendar.AUGUST, 16)));
    put(localPeople, createPerson("Sour", "Doe", createDate(2012, Calendar.DECEMBER, 1)));
    put(localPeople, createPerson("Jack", "Handy", createDate(1977, Calendar.MAY, 10)));
    put(localPeople, createPerson("Sandy", "Handy", createDate(1977, Calendar.MARCH, 3)));
    put(localPeople, createPerson("Jack", "Black", createDate(1972, Calendar.JUNE, 26)));
    put(localPeople, createPerson("Ben", "Dover", createDate(1969, Calendar.MAY, 5)));
    put(localPeople, createPerson("Ima", "Pigg", createDate(1975, Calendar.JULY, 17)));

    assertThat(localPeople.size(), is(equalTo(10)));
}

From source file:org.lieuofs.commune.biz.GestionMutationCommuneTest.java

@Test
public void testRechercherMutationJurassienne() {
    // Recherche des mutations sur le canton du Jura
    // Lors de la cration du canton le 01.01.1979, 82 communes ont migr du canton de Berne
    // dans le canton du Jura.
    MutationCommuneCritere critere = new MutationCommuneCritere();
    critere.setCodeCanton("BE");
    Calendar cal = Calendar.getInstance();
    cal.set(1978, Calendar.DECEMBER, 31);
    critere.setDateDebut(cal.getTime());
    cal.add(Calendar.DATE, 1);//  w  ww.  ja va2  s  .  c  o  m
    critere.setDateFin(cal.getTime());
    List<IMutationCommune> mutations = gestionnaire.rechercherMutation(critere);
    List<String> descriptions = new ArrayList<String>();
    for (IMutationCommune mut : mutations) {
        descriptions.add(mut.getDescription());
    }
    assertThat(mutations).hasSize(82);
}

From source file:moviemanager.backend.RelationshipManagerTest.java

@Test
public void addPersonAsDirector() {
    log.info("Testing adding person as director...");

    String personName = "John Doe (personAsDirector)";
    String movieTitle = "Director Movie";

    // create movie
    Movie movie = new Movie();
    movie.setTitle(movieTitle);/*ww w .  ja  va 2s  .  c o m*/
    movie.setYear(1990);
    movie.setLength(180);
    movieManager.createMovie(movie);
    assertNotNull(movie);

    //create person
    Calendar calendar = new GregorianCalendar(1995, Calendar.DECEMBER, 1);
    Person person = new Person(personName, calendar);
    personManager.createPerson(person);
    assertNotNull(person);

    // add to relationship dtb and check it was added
    relationManager.addPersonToRole(person, movie, Consts.DIRECTOR);
    assertTrue(relationManager.checkRole(person, movie, Consts.DIRECTOR));

    // check if person from relationship dtb is the same as person inserted
    List<Person> resultPerson = relationManager.personsOfMovie(movie);
    assertNotNull(resultPerson);
    assertEquals(resultPerson.get(0).getName(), personName);
    assertEquals(resultPerson.get(0), person);

    // check if movie from relationship dtb is the same as movie inserted
    List<Movie> resultMovie = relationManager.moviesOfPerson(person);
    assertNotNull(resultMovie);
    assertEquals(resultMovie.get(0).getTitle(), movieTitle);
    assertEquals(resultMovie.get(0), movie);
}

From source file:org.spring.data.gemfire.cache.SpringGemfireTemplateTests.java

@Before
public void setup() {
    assertNotNull("The '/Customers' Region was not properly configured and initialized!", customers);

    if (customers.isEmpty()) {
        assertEquals(0, customers.size());

        put("Jon", "Doe", createDate(1959, Calendar.FEBRUARY, 14));
        put("Jane", "Doe", createDate(1966, Calendar.APRIL, 4));
        put("Fro", "Doe", createDate(2002, Calendar.DECEMBER, 16));

        expectedCustomers = new ArrayList<>(3);
        expectedCustomers.add(put("Sour", "Doe", createDate(1983, Calendar.OCTOBER, 31)));
        expectedCustomers.add(put("Pie", "Doe", createDate(1988, Calendar.NOVEMBER, 22)));
        expectedCustomers.add(put("Cookie", "Doe", createDate(1991, Calendar.MAY, 27)));

        assertFalse(expectedCustomers.isEmpty());
        assertEquals(3, expectedCustomers.size());
    }/*from   w  ww  . java  2 s.c  om*/
}

From source file:org.techytax.util.DateHelper.java

public static FiscalPeriod getLastVatPeriodPreviousYear() {
    Calendar cal = new GregorianCalendar();
    cal.setTime(new Date());
    cal.add(Calendar.YEAR, -1);/* w w  w.  j  a va  2 s.com*/
    cal.set(Calendar.MONTH, Calendar.OCTOBER);
    cal.set(Calendar.DAY_OF_MONTH, 1);
    Date beginDatum = cal.getTime();
    cal.set(Calendar.MONTH, Calendar.DECEMBER);
    cal.set(Calendar.DAY_OF_MONTH, 31);
    Date eindDatum = cal.getTime();
    return new FiscalPeriod(beginDatum, eindDatum);
}

From source file:com.mycompany.CRMFly.serviceLayer.ClientsServiceImpl.java

@Transactional
public Map<Date, Double> getSumsFotDates(Clients client) {
    Long id = client.getId();//ww  w . ja  v a2s. c  om

    Calendar calendar = new GregorianCalendar();
    Integer monthDifference = 0;
    if (calendar.get(Calendar.MONTH) == Calendar.JANUARY || calendar.get(Calendar.MONTH) == Calendar.APRIL
            || calendar.get(Calendar.MONTH) == Calendar.JULY
            || calendar.get(Calendar.MONTH) == Calendar.OCTOBER) {
        monthDifference = 0;
    } else if (calendar.get(Calendar.MONTH) == Calendar.FEBRUARY || calendar.get(Calendar.MONTH) == Calendar.MAY
            || calendar.get(Calendar.MONTH) == Calendar.AUGUST
            || calendar.get(Calendar.MONTH) == Calendar.NOVEMBER) {
        monthDifference = -1;
    } else if (calendar.get(Calendar.MONTH) == Calendar.MARCH || calendar.get(Calendar.MONTH) == Calendar.JUNE
            || calendar.get(Calendar.MONTH) == Calendar.SEPTEMBER
            || calendar.get(Calendar.MONTH) == Calendar.DECEMBER)
        monthDifference = -2;
    //     Integer dayDifference = -calendar.get(Calendar.DAY_OF_MONTH);
    calendar.add(Calendar.MONTH, monthDifference);
    calendar.set(Calendar.DAY_OF_MONTH, 1);
    calendar.set(Calendar.HOUR, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    calendar.set(Calendar.MILLISECOND, 0);
    //      calendar.add(Calendar.DAY_OF_MONTH, dayDifference-1);

    Date beginningOfQuarter = calendar.getTime();
    Double thisQuarterSum = 0.0;
    calendar.add(Calendar.MONTH, -3);
    Date QuarterBackOne = calendar.getTime();
    Double QuarterBackOneSum = 0.0;
    calendar.add(Calendar.MONTH, -3);
    Date QuarterBackTwo = calendar.getTime();
    Double QuarterBackTwoSum = 0.0;
    calendar.add(Calendar.MONTH, -3);
    Date QuarterBackThree = calendar.getTime();
    Double QuarterBackThreeSum = 0.0;

    List<Contracts> contracts = clientsDAO.getContractsForClient(id);
    HashMap<Date, Double> sums = new HashMap<Date, Double>();
    for (Contracts contract : contracts) {
        Date date = contract.getBegin_date();
        if (date.after(beginningOfQuarter))
            thisQuarterSum += contract.getTotalSum();
        else if (date.after(QuarterBackOne))
            QuarterBackOneSum += contract.getTotalSum();
        else if (date.after(QuarterBackTwo))
            QuarterBackTwoSum += contract.getTotalSum();
        else if (date.after(QuarterBackThree))
            QuarterBackThreeSum += contract.getTotalSum();
    }
    sums.put(beginningOfQuarter, thisQuarterSum);
    sums.put(QuarterBackOne, QuarterBackOneSum);
    sums.put(QuarterBackTwo, QuarterBackTwoSum);
    sums.put(QuarterBackThree, QuarterBackThreeSum);
    return sums;
}

From source file:ch.puzzle.itc.mobiliar.business.generator.control.extracted.ResourceDependencyResolverServiceTest.java

@Test
public void testFindNearestRelease() {
    // given/*from  ww w. j a  v a 2 s.  c  om*/
    Calendar cal = new GregorianCalendar();

    cal.set(2001, Calendar.JANUARY, 1);
    ReleaseEntity release1 = createRelease(1, new Date(cal.getTimeInMillis()));

    cal.set(2013, Calendar.JANUARY, 1);
    ReleaseEntity release2 = createRelease(2, new Date(cal.getTimeInMillis()));

    cal.set(2013, Calendar.JANUARY, 23);
    ReleaseEntity release3 = createRelease(3, new Date(cal.getTimeInMillis()));

    cal.set(2013, Calendar.AUGUST, 8);
    ReleaseEntity release4 = createRelease(4, new Date(cal.getTimeInMillis()));

    cal.set(2013, Calendar.DECEMBER, 31);
    ReleaseEntity release5 = createRelease(5, new Date(cal.getTimeInMillis()));

    cal.set(2014, Calendar.NOVEMBER, 10);
    ReleaseEntity release6 = createRelease(6, new Date(cal.getTimeInMillis()));

    SortedSet<ReleaseEntity> releases = new TreeSet<ReleaseEntity>();

    // when only past release exists
    releases.add(release1);
    cal.set(2013, Calendar.JANUARY, 10);
    ReleaseEntity nearestRelease = service.findMostRelevantRelease(releases, new Date(cal.getTimeInMillis()));

    // then
    assertEquals(release1.getId(), nearestRelease.getId());

    // when there are multiple past releases
    releases.add(release2);
    releases.add(release3);
    cal.set(2013, Calendar.FEBRUARY, 10);
    nearestRelease = service.findMostRelevantRelease(releases, new Date(cal.getTimeInMillis()));

    // then
    assertEquals(release3.getId(), nearestRelease.getId());

    // when there is one future release
    releases.add(release4);
    cal.set(2013, Calendar.FEBRUARY, 10);
    nearestRelease = service.findMostRelevantRelease(releases, new Date(cal.getTimeInMillis()));

    // then
    assertEquals(release4.getId(), nearestRelease.getId());

    // when there are multiple future releases
    cal.set(2013, Calendar.AUGUST, 9);
    releases.add(release5);
    releases.add(release6);
    nearestRelease = service.findMostRelevantRelease(releases, new Date(cal.getTimeInMillis()));

    // then
    Assert.assertEquals(release5.getId(), nearestRelease.getId());
}

From source file:com.ocs.dynamo.utils.DateUtils.java

/**
 * Converts a date to its corresponding week code
 * /*w w w. j a v  a  2  s  . co m*/
 * @param date
 * @return
 */
public static String toWeekCode(Date date) {
    if (date != null) {
        Calendar calendar = new GregorianCalendar(DynamoConstants.DEFAULT_LOCALE);
        calendar.setTime(date);
        int year = calendar.get(Calendar.YEAR);
        int week = calendar.get(Calendar.WEEK_OF_YEAR);
        int month = calendar.get(Calendar.MONTH);

        // if the week number is reported as 1, but we are in December,
        // then we have an "overflow"
        if (week == FIRST_WEEK_NUMBER && month == Calendar.DECEMBER) {
            year++;
        }

        return year + "-" + StringUtils.leftPad(Integer.toString(week), 2, "0");
    }
    return null;
}

From source file:mailjimp.service.TestMailJimpJsonService.java

@Test
public void testListMembers() {
    try {//from   w w w  . j  a  v  a  2  s.  c  o m
        Calendar i = Calendar.getInstance();
        i.set(Calendar.YEAR, 2009);
        i.set(Calendar.MONTH, Calendar.DECEMBER);
        i.set(Calendar.DATE, 15);
        log.debug("Testing list members");
        List<MemberResponseInfo> content = mSvc.listMembers(listId, MemberStatus.subscribed, i.getTime(), null,
                null);
        log.debug("Lists Content: {}", content);
    } catch (MailJimpException mje) {
        processError(mje);
    }
}