Example usage for java.util Calendar OCTOBER

List of usage examples for java.util Calendar OCTOBER

Introduction

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

Prototype

int OCTOBER

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

Click Source Link

Document

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

Usage

From source file:com.github.dozermapper.core.functional_tests.MapTypeTest.java

private void runMapGetSetMethodTest(String mapId) {
    // Test that custom field converter works for Custom Map Types
    mapper = getMapper("mappings/mapGetSetMethodMapping.xml");
    CustomMap src = newInstance(CustomMap.class);
    src.putValue("fieldA", "someStringValue");
    src.putValue("field2", "someOtherStringValue");
    src.putValue("fieldC", "1");
    src.putValue("fieldD", "2");
    src.putValue("fieldE", "10-15-2005");

    SimpleObj dest = mapper.map(src, SimpleObj.class, mapId);
    assertEquals("wrong value for field1", src.getValue("fieldA"), dest.getField1());
    assertEquals("wrong value for field2", src.getValue("field2"), dest.getField2());
    assertEquals("wrong value for field3", Integer.valueOf("1"), dest.getField3());
    assertEquals("wrong value for field4", Integer.valueOf("2"), dest.getField4());
    Calendar expected = Calendar.getInstance();
    expected.set(2005, 10, 15);/*  w  ww  .ja  va2  s  .co m*/
    assertEquals(expected.get(Calendar.YEAR), dest.getField5().get(Calendar.YEAR));
    assertEquals(Calendar.OCTOBER, dest.getField5().get(Calendar.MONTH));
    assertEquals(expected.get(Calendar.DATE), dest.getField5().get(Calendar.DATE));

    // Remap to test bi-directional mapping
    CustomMap remappedSrc = mapper.map(dest, CustomMap.class, mapId);
    assertTrue("remapped src should equal original src",
            EqualsBuilder.reflectionEquals(src.getMap(), remappedSrc.getMap()));
}

From source file:org.dozer.functional_tests.MapTypeTest.java

private void runMapGetSetMethodTest(String mapId) throws Exception {
    // Test that custom field converter works for Custom Map Types
    mapper = getMapper(new String[] { "mapGetSetMethodMapping.xml" });
    CustomMap src = newInstance(CustomMap.class);
    src.putValue("fieldA", "someStringValue");
    src.putValue("field2", "someOtherStringValue");
    src.putValue("fieldC", "1");
    src.putValue("fieldD", "2");
    src.putValue("fieldE", "10-15-2005");

    SimpleObj dest = mapper.map(src, SimpleObj.class, mapId);
    assertEquals("wrong value for field1", src.getValue("fieldA"), dest.getField1());
    assertEquals("wrong value for field2", src.getValue("field2"), dest.getField2());
    assertEquals("wrong value for field3", Integer.valueOf("1"), dest.getField3());
    assertEquals("wrong value for field4", Integer.valueOf("2"), dest.getField4());
    Calendar expected = Calendar.getInstance();
    expected.set(2005, 10, 15);/*from ww  w  . j  a  va2 s  .co  m*/
    assertEquals(expected.get(Calendar.YEAR), dest.getField5().get(Calendar.YEAR));
    assertEquals(Calendar.OCTOBER, dest.getField5().get(Calendar.MONTH));
    assertEquals(expected.get(Calendar.DATE), dest.getField5().get(Calendar.DATE));

    // Remap to test bi-directional mapping
    CustomMap remappedSrc = mapper.map(dest, CustomMap.class, mapId);
    assertTrue("remapped src should equal original src",
            EqualsBuilder.reflectionEquals(src.getMap(), remappedSrc.getMap()));
}

From source file:cn.mljia.common.notify.utils.DateUtils.java

/**
 * ?/*from  w w  w .  j a  va2 s.  c  o  m*/
 * 
 * @param date
 * @return
 */
public static Date[] getSeasonDate(Date date) {
    Date[] season = new Date[3];

    Calendar c = Calendar.getInstance();
    c.setTime(date);

    int nSeason = getSeason(date);
    if (nSeason == 1) {// 
        c.set(Calendar.MONTH, Calendar.JANUARY);
        season[0] = c.getTime();
        c.set(Calendar.MONTH, Calendar.FEBRUARY);
        season[1] = c.getTime();
        c.set(Calendar.MONTH, Calendar.MARCH);
        season[2] = c.getTime();
    } else if (nSeason == 2) {// 
        c.set(Calendar.MONTH, Calendar.APRIL);
        season[0] = c.getTime();
        c.set(Calendar.MONTH, Calendar.MAY);
        season[1] = c.getTime();
        c.set(Calendar.MONTH, Calendar.JUNE);
        season[2] = c.getTime();
    } else if (nSeason == 3) {// 
        c.set(Calendar.MONTH, Calendar.JULY);
        season[0] = c.getTime();
        c.set(Calendar.MONTH, Calendar.AUGUST);
        season[1] = c.getTime();
        c.set(Calendar.MONTH, Calendar.SEPTEMBER);
        season[2] = c.getTime();
    } else if (nSeason == 4) {// 
        c.set(Calendar.MONTH, Calendar.OCTOBER);
        season[0] = c.getTime();
        c.set(Calendar.MONTH, Calendar.NOVEMBER);
        season[1] = c.getTime();
        c.set(Calendar.MONTH, Calendar.DECEMBER);
        season[2] = c.getTime();
    }
    return season;
}

From source file:cn.mljia.common.notify.utils.DateUtils.java

/**
 * //ww w  .j a  v  a2 s .c om
 * 1  2  3  4 
 * 
 * @param date
 * @return
 */
public static int getSeason(Date date) {

    int season = 0;

    Calendar c = Calendar.getInstance();
    c.setTime(date);
    int month = c.get(Calendar.MONTH);
    switch (month) {
    case Calendar.JANUARY:
    case Calendar.FEBRUARY:
    case Calendar.MARCH:
        season = 1;
        break;
    case Calendar.APRIL:
    case Calendar.MAY:
    case Calendar.JUNE:
        season = 2;
        break;
    case Calendar.JULY:
    case Calendar.AUGUST:
    case Calendar.SEPTEMBER:
        season = 3;
        break;
    case Calendar.OCTOBER:
    case Calendar.NOVEMBER:
    case Calendar.DECEMBER:
        season = 4;
        break;
    default:
        break;
    }
    return season;
}

From source file:org.kuali.kfs.module.endow.document.service.impl.CurrentTaxLotServiceImpl.java

/**
 * This method will check the current month and set the calendar to that month
 * //w  w w . j a  va2  s . c  om
 * @param month month to set the calendar, currentDate currentDate
 * @return calendar calendar is set to the month selected
 */
protected Calendar setCaledarWithMonth(String month, Date lastPaymentDate) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(lastPaymentDate);

    int calendarMonth = 1;

    if (EndowConstants.FrequencyMonths.JANUARY.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.JANUARY;
    } else if (EndowConstants.FrequencyMonths.FEBRUARY.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.FEBRUARY;
    } else if (EndowConstants.FrequencyMonths.MARCH.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.MARCH;
    } else if (EndowConstants.FrequencyMonths.APRIL.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.APRIL;
    } else if (EndowConstants.FrequencyMonths.MAY.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.MAY;
    } else if (EndowConstants.FrequencyMonths.JUNE.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.JUNE;
    } else if (EndowConstants.FrequencyMonths.JULY.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.JULY;
    } else if (EndowConstants.FrequencyMonths.AUGUST.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.AUGUST;
    } else if (EndowConstants.FrequencyMonths.SEPTEMBER.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.SEPTEMBER;
    } else if (EndowConstants.FrequencyMonths.OCTOBER.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.OCTOBER;
    } else if (EndowConstants.FrequencyMonths.NOVEMBER.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.NOVEMBER;
    } else if (EndowConstants.FrequencyMonths.DECEMBER.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.DECEMBER;
    }

    calendar.set(Calendar.MONTH, calendarMonth);

    return calendar;
}

From source file:gov.nih.nci.firebird.selenium2.tests.profile.AssociatedOrganizationTabTest.java

private void checkForExpirationBeforeEffectiveDateError(final LabCertificatesDialog labCertificatesDialog) {
    Date today = new Date();
    labCertificatesDialog.getHelper().setEffectiveDate(DateUtils.setMonths(today, Calendar.DECEMBER));
    labCertificatesDialog.getHelper().setExpirationDate(DateUtils.setMonths(today, Calendar.OCTOBER));
    ExpectedValidationFailure expectedValidationFailure = new ExpectedValidationFailure(
            "error.expiration.date.before.effective");
    expectedValidationFailure.assertFailureOccurs(new FailingAction() {
        @Override//from   w w  w . j  av a  2  s . c  o  m
        public void perform() {
            labCertificatesDialog.clickSave();
        }
    });
}

From source file:com.frey.repo.DateUtil.java

/**
 * ?//www .ja  va2 s  .c o  m
 */
public static int getPassDayOfSeason(Date date) {
    int day = 0;

    Date[] seasonDates = getSeasonDate(date);

    Calendar c = Calendar.getInstance();
    c.setTime(date);
    int month = c.get(Calendar.MONTH);

    if (month == Calendar.JANUARY || month == Calendar.APRIL || month == Calendar.JULY
            || month == Calendar.OCTOBER) {//
        day = getPassDayOfMonth(seasonDates[0]);
    } else if (month == Calendar.FEBRUARY || month == Calendar.MAY || month == Calendar.AUGUST
            || month == Calendar.NOVEMBER) {//
        day = getDayOfMonth(seasonDates[0]) + getPassDayOfMonth(seasonDates[1]);
    } else if (month == Calendar.MARCH || month == Calendar.JUNE || month == Calendar.SEPTEMBER
            || month == Calendar.DECEMBER) {//
        day = getDayOfMonth(seasonDates[0]) + getDayOfMonth(seasonDates[1]) + getPassDayOfMonth(seasonDates[2]);
    }
    return day;
}

From source file:com.frey.repo.DateUtil.java

/**
 * ?/*from   w  ww  . jav  a  2s  .  c  o m*/
 */
public static Date[] getSeasonDate(Date date) {
    Date[] season = new Date[3];

    Calendar c = Calendar.getInstance();
    c.setTime(date);

    int nSeason = getSeason(date);
    if (nSeason == 1) {//
        c.set(Calendar.MONTH, Calendar.JANUARY);
        season[0] = c.getTime();
        c.set(Calendar.MONTH, Calendar.FEBRUARY);
        season[1] = c.getTime();
        c.set(Calendar.MONTH, Calendar.MARCH);
        season[2] = c.getTime();
    } else if (nSeason == 2) {//
        c.set(Calendar.MONTH, Calendar.APRIL);
        season[0] = c.getTime();
        c.set(Calendar.MONTH, Calendar.MAY);
        season[1] = c.getTime();
        c.set(Calendar.MONTH, Calendar.JUNE);
        season[2] = c.getTime();
    } else if (nSeason == 3) {//
        c.set(Calendar.MONTH, Calendar.JULY);
        season[0] = c.getTime();
        c.set(Calendar.MONTH, Calendar.AUGUST);
        season[1] = c.getTime();
        c.set(Calendar.MONTH, Calendar.SEPTEMBER);
        season[2] = c.getTime();
    } else if (nSeason == 4) {//
        c.set(Calendar.MONTH, Calendar.OCTOBER);
        season[0] = c.getTime();
        c.set(Calendar.MONTH, Calendar.NOVEMBER);
        season[1] = c.getTime();
        c.set(Calendar.MONTH, Calendar.DECEMBER);
        season[2] = c.getTime();
    }
    return season;
}

From source file:org.nuxeo.ecm.platform.rendition.service.TestRenditionService.java

@Ignore("NXP-20878: failing randomly")
@Test// ww  w.  j  a  v a2s.  c  om
public void shouldNotScheduleRedundantLazyRenditionBuilderWorks() throws Exception {
    final String renditionName = "lazyAutomation";
    final String sourceDocumentModificationDatePropertyName = "dc:issued";
    Calendar issued = (Calendar) new GregorianCalendar(2010, Calendar.OCTOBER, 10, 10, 10, 10);
    String desc = CYCLIC_BARRIER_DESCRIPTION;
    DocumentModel folder = session.createDocumentModel("/", "dummy", "Folder");
    folder.setPropertyValue("dc:title", folder.getName());
    folder.setPropertyValue("dc:description", desc);
    folder.setPropertyValue(sourceDocumentModificationDatePropertyName, issued);
    folder = session.createDocument(folder);
    session.save();
    nextTransaction();
    eventService.waitForAsyncCompletion();

    for (int i = 0; i < 3; i++) {
        folder = session.getDocument(folder.getRef());

        Rendition rendition = renditionService.getRendition(folder, renditionName, true);
        assertNotNull(rendition);
        assertTrue(rendition.getBlob().getMimeType().contains(LazyRendition.EMPTY_MARKER));
        if (i == 0) {
            cyclicBarrier.await();
        }

        issued = (Calendar) folder.getPropertyValue(sourceDocumentModificationDatePropertyName);
        issued.add(Calendar.HOUR_OF_DAY, 1);
        folder.setPropertyValue(sourceDocumentModificationDatePropertyName, issued);
        desc = "description" + Integer.toString(i);
        folder.setPropertyValue("dc:description", desc);
        session.saveDocument(folder);
        session.save();
        if (TransactionHelper.isTransactionActiveOrMarkedRollback()) {
            TransactionHelper.commitOrRollbackTransaction();
            TransactionHelper.startTransaction();
        }
        if (i == 0) {
            cyclicBarrier.await();
        }
    }

    String queueId = works.getCategoryQueueId(AbstractRenditionBuilderWork.CATEGORY);
    assertEquals(1, works.listWorkIds(queueId, Work.State.RUNNING).size());
    assertEquals(1, works.listWorkIds(queueId, Work.State.SCHEDULED).size());

    cyclicBarrier.await();

    eventService.waitForAsyncCompletion(5000);

    folder = session.getDocument(folder.getRef());
    for (int i = 0; i < 5; i++) {
        Rendition rendition = renditionService.getRendition(folder, renditionName, true);
        assertNotNull(rendition);
        assertNotNull(rendition.getBlob());
        String mimeType = rendition.getBlob().getMimeType();
        if (mimeType != null) {
            if (mimeType.contains(LazyRendition.EMPTY_MARKER)) {
                Thread.sleep(1000);
                nextTransaction();
                eventService.waitForAsyncCompletion(5000);
                continue;
            } else if (mimeType.contains(LazyRendition.ERROR_MARKER)) {
                fail("Error generating rendition for folder");
            }
        }
        String content = rendition.getBlob().getString();
        assertTrue(content.contains("dummy"));
        assertTrue(content.contains(desc));
        return;
    }
    fail("Could not retrieve rendition for folder");
}

From source file:org.apache.jena.graph.test.TestTypedLiterals.java

public void testDateTime_18() {
    SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, "America/Los_Angeles");

    // set up rules for daylight savings time
    pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
    pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
    // create a GregorianCalendar with the Pacific Daylight time  zone
    Calendar ncal = new GregorianCalendar(pdt);
    ncal.set(2004, 02, 21, 12, 50, 42);//before daylight savings time
    ncal.set(Calendar.MILLISECOND, 0);
    //System.err.println("cal is: "+ncal);
    Literal l1 = m.createTypedLiteral(ncal);
    assertEquals("DateTime from date", XSDDatatype.XSDdateTime, l1.getDatatype());
    assertEquals("DateTime from date", XSDDateTime.class, l1.getValue().getClass());
    assertEquals("DateTime from date", "2004-03-21T20:50:42Z", l1.getValue().toString());
    //System.err.println("date is: "+ncal.getTime());
    ncal = new GregorianCalendar(pdt);
    ncal.set(2004, 03, 21, 12, 50, 42);//within daylight savings time
    ncal.set(Calendar.MILLISECOND, 0);
    //System.err.println("cal is: "+ncal);
    l1 = m.createTypedLiteral(ncal);/*from ww w .  j  a v a 2  s. c om*/
    assertEquals("DateTime from date", XSDDatatype.XSDdateTime, l1.getDatatype());
    assertEquals("DateTime from date", XSDDateTime.class, l1.getValue().getClass());
    assertEquals("DateTime from date", "2004-04-21T19:50:42Z", l1.getValue().toString());
    //System.err.println("date is: "+ncal.getTime());

}