Example usage for java.util Calendar JULY

List of usage examples for java.util Calendar JULY

Introduction

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

Prototype

int JULY

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

Click Source Link

Document

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

Usage

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

/**
 * ?//from   ww  w . j a v  a2 s . c om
 * 
 * @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:org.apache.logging.log4j.core.util.datetime.FastDateParserTest.java

@Test
public void testParseOffset() {
    final DateParser parser = getInstance(YMD_SLASH);
    final Date date = parser.parse("Today is 2015/07/04", new ParsePosition(9));

    final Calendar cal = Calendar.getInstance();
    cal.clear();//from  w  ww.ja v  a  2 s . co m
    cal.set(2015, Calendar.JULY, 4);
    Assert.assertEquals(cal.getTime(), date);
}

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

/**
 * //from   w ww  . ja  v  a2 s  .com
 * 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 ww .ja v  a  2s .  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:com.frey.repo.DateUtil.java

/**
 * ?/*from   w  w w.  java 2 s.  co 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  .j  ava2s.  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.automation.server.test.EmbeddedAutomationClientTest.java

/**
 * @since 7.4/*ww  w . j  a  va 2  s .c o m*/
 */
@Test
public void canSendCalendarParameters() throws IOException {
    Document root = (Document) super.session.newRequest(FetchDocument.ID).set("value", "/").execute();
    OperationRequest request = session.newRequest(AddPermission.ID);
    GregorianCalendar begin = new GregorianCalendar(2015, Calendar.JUNE, 20, 12, 34, 56);
    GregorianCalendar end = new GregorianCalendar(2015, Calendar.JULY, 14, 12, 34, 56);
    request.setInput(root).set("username", "members").set("permission", "Write").set("begin", begin)
            .set("end", end).execute();
    // TODO NXP-17232 to use context parameters in json payload response with automation and automation client.
    // Once NXP-17232 resolved: assertions possible to get related doc ACLs.
}

From source file:org.mifos.accounts.loan.business.LoanBOIntegrationTest.java

public void testApplyPeriodicFeeWithHoliday() throws Exception {
    Date startDate = DateUtils.getDate(2008, Calendar.MAY, 23);
    new DateTimeService().setCurrentDateTime(new DateTime(startDate));

    accountBO = getLoanAccount(startDate, AccountState.LOAN_APPROVED);

    Money intialTotalFeeAmount = ((LoanBO) accountBO).getLoanSummary().getOriginalFees();
    TestObjectFactory.flushandCloseSession();
    accountBO = TestObjectFactory.getObject(AccountBO.class, accountBO.getAccountId());

    // create holiday on first installment date
    HolidayBO holiday = createHoliday(DateUtils.getDate(2008, Calendar.MAY, 30));

    try {/*from   www.  j a  v a 2s.  com*/
        LoanBO loanBO = (LoanBO) accountBO;
        loanBO.updateLoan(loanBO.isInterestDeductedAtDisbursement(), loanBO.getLoanAmount(),
                loanBO.getInterestRate(), loanBO.getNoOfInstallments(), loanBO.getDisbursementDate(),
                loanBO.getGracePeriodDuration(), loanBO.getBusinessActivityId(), "Loan account updated", null,
                null, false, null, null);

        FeeBO periodicFee = TestObjectFactory.createPeriodicAmountFee("Periodic Fee", FeeCategory.LOAN, "25",
                RecurrenceType.WEEKLY, EVERY_WEEK);

        UserContext uc = TestUtils.makeUser();
        loanBO.setUserContext(uc);
        loanBO.applyCharge(periodicFee.getFeeId(),
                ((AmountFeeBO) periodicFee).getFeeAmount().getAmountDoubleValue());
        StaticHibernateUtil.commitTransaction();
        StaticHibernateUtil.closeSession();

        Map<String, String> fees1 = new HashMap<String, String>();
        fees1.put("Mainatnence Fee", "100.0");

        Map<String, String> fees2 = new HashMap<String, String>();
        fees2.put("Mainatnence Fee", "100.0");
        fees2.put("Periodic Fee", "25.0");

        LoanScheduleEntity[] paymentsArray = LoanBOTestUtils
                .getSortedAccountActionDateEntity(loanBO.getAccountActionDates());

        List<Date> installmentDates = new ArrayList<Date>();
        List<Date> feeDates = new ArrayList<Date>();
        for (LoanScheduleEntity loanScheduleEntity : paymentsArray) {
            installmentDates.add(loanScheduleEntity.getActionDate());
            for (AccountFeesActionDetailEntity accountFeesActionDetailEntity : loanScheduleEntity
                    .getAccountFeesActionDetails()) {
                Date feeDate = accountFeesActionDetailEntity.getAccountActionDate().getActionDate();
                feeDates.add(feeDate);
            }
        }

        Assert.assertEquals(6, paymentsArray.length);

        checkFees(fees2, paymentsArray[0], false);
        checkFees(fees2, paymentsArray[1], false);
        checkFees(fees2, paymentsArray[2], false);
        checkFees(fees2, paymentsArray[3], false);
        checkFees(fees2, paymentsArray[4], false);
        checkFees(fees2, paymentsArray[5], false);

        List<Date> expectedDates = new ArrayList<Date>();
        expectedDates.add(DateUtils.getDate(2008, Calendar.MAY, 31));
        expectedDates.add(DateUtils.getDate(2008, Calendar.JUNE, 06));
        expectedDates.add(DateUtils.getDate(2008, Calendar.JUNE, 13));
        expectedDates.add(DateUtils.getDate(2008, Calendar.JUNE, 20));
        expectedDates.add(DateUtils.getDate(2008, Calendar.JUNE, 27));
        expectedDates.add(DateUtils.getDate(2008, Calendar.JULY, 04));

        int i = 0;
        for (AccountActionDateEntity accountActionDateEntity : accountBO.getAccountActionDates()) {
            LoanScheduleEntity loanScheduleEntity = (LoanScheduleEntity) accountActionDateEntity;
            Assert.assertEquals(expectedDates.get(i++), loanScheduleEntity.getActionDate());
            Assert.assertEquals(new Money(getCurrency(), "125"), loanScheduleEntity.getTotalFees());
        }

        Assert.assertEquals(intialTotalFeeAmount.add(new Money(getCurrency(), "750.0")),
                loanBO.getLoanSummary().getOriginalFees());
    } finally {
        // make sure that we don't leave any persistent changes that could
        // affect subsequent tests
        new DateTimeService().resetToCurrentSystemDateTime();
        deleteHoliday(holiday);
    }
}

From source file:org.exist.xquery.modules.mail.SendEmailFunction.java

/**
 * Returns the current date and time in an RFC822 format, suitable for an email Date Header
 *
 * @return      RFC822 formated date and time as a String
 *///from w w w  . j  a v a  2  s  . co  m
private String getDateRFC822() {

    String dateString = new String();
    final Calendar rightNow = Calendar.getInstance();

    //Day of the week
    switch (rightNow.get(Calendar.DAY_OF_WEEK)) {
    case Calendar.MONDAY:
        dateString = "Mon";
        break;

    case Calendar.TUESDAY:
        dateString = "Tue";
        break;

    case Calendar.WEDNESDAY:
        dateString = "Wed";
        break;

    case Calendar.THURSDAY:
        dateString = "Thu";
        break;

    case Calendar.FRIDAY:
        dateString = "Fri";
        break;

    case Calendar.SATURDAY:
        dateString = "Sat";
        break;

    case Calendar.SUNDAY:
        dateString = "Sun";
        break;
    }

    dateString += ", ";

    //Date
    dateString += rightNow.get(Calendar.DAY_OF_MONTH);
    dateString += " ";

    //Month
    switch (rightNow.get(Calendar.MONTH)) {
    case Calendar.JANUARY:
        dateString += "Jan";
        break;

    case Calendar.FEBRUARY:
        dateString += "Feb";
        break;

    case Calendar.MARCH:
        dateString += "Mar";
        break;

    case Calendar.APRIL:
        dateString += "Apr";
        break;

    case Calendar.MAY:
        dateString += "May";
        break;

    case Calendar.JUNE:
        dateString += "Jun";
        break;

    case Calendar.JULY:
        dateString += "Jul";
        break;

    case Calendar.AUGUST:
        dateString += "Aug";
        break;

    case Calendar.SEPTEMBER:
        dateString += "Sep";
        break;

    case Calendar.OCTOBER:
        dateString += "Oct";
        break;

    case Calendar.NOVEMBER:
        dateString += "Nov";
        break;

    case Calendar.DECEMBER:
        dateString += "Dec";
        break;
    }
    dateString += " ";

    //Year
    dateString += rightNow.get(Calendar.YEAR);
    dateString += " ";

    //Time
    String tHour = Integer.toString(rightNow.get(Calendar.HOUR_OF_DAY));
    if (tHour.length() == 1) {
        tHour = "0" + tHour;
    }

    String tMinute = Integer.toString(rightNow.get(Calendar.MINUTE));
    if (tMinute.length() == 1) {
        tMinute = "0" + tMinute;
    }

    String tSecond = Integer.toString(rightNow.get(Calendar.SECOND));
    if (tSecond.length() == 1) {
        tSecond = "0" + tSecond;
    }

    dateString += tHour + ":" + tMinute + ":" + tSecond + " ";

    //TimeZone Correction
    String tzSign = new String();
    String tzHours = new String();
    String tzMinutes = new String();

    final TimeZone thisTZ = rightNow.getTimeZone();
    int tzOffset = thisTZ.getOffset(rightNow.getTime().getTime()); //get timezone offset in milliseconds
    tzOffset = (tzOffset / 1000); //convert to seconds
    tzOffset = (tzOffset / 60); //convert to minutes

    //Sign
    if (tzOffset > 1) {
        tzSign = "+";
    } else {
        tzSign = "-";
        tzOffset *= -1;
    }

    //Calc Hours and Minutes?
    if (tzOffset >= 60) {
        //Minutes and Hours
        tzHours += (tzOffset / 60); //hours

        // do we need to prepend a 0
        if (tzHours.length() == 1) {
            tzHours = "0" + tzHours;
        }

        tzMinutes += (tzOffset % 60); //minutes

        // do we need to prepend a 0
        if (tzMinutes.length() == 1) {
            tzMinutes = "0" + tzMinutes;
        }
    } else {
        //Just Minutes
        tzHours = "00";
        tzMinutes += tzOffset;
        // do we need to prepend a 0
        if (tzMinutes.length() == 1) {
            tzMinutes = "0" + tzMinutes;
        }
    }

    dateString += tzSign + tzHours + tzMinutes;

    return dateString;
}

From source file:org.mifos.accounts.loan.business.LoanBOIntegrationTest.java

public void testPeriodicFeeWithHoliday() throws Exception {
    Date startDate = DateUtils.getDate(2008, Calendar.MAY, 23);
    new DateTimeService().setCurrentDateTime(new DateTime(startDate));

    accountBO = getLoanAccount(startDate, AccountState.LOAN_APPROVED);

    Money intialTotalFeeAmount = ((LoanBO) accountBO).getLoanSummary().getOriginalFees();
    TestObjectFactory.flushandCloseSession();
    accountBO = TestObjectFactory.getObject(AccountBO.class, accountBO.getAccountId());

    // create holiday on first installment date
    HolidayBO holiday = createHoliday(DateUtils.getDate(2008, Calendar.MAY, 30));

    try {//from w ww  .j a  v a  2s. c om
        LoanBO loanBO = (LoanBO) accountBO;
        loanBO.updateLoan(loanBO.isInterestDeductedAtDisbursement(), loanBO.getLoanAmount(),
                loanBO.getInterestRate(), loanBO.getNoOfInstallments(), loanBO.getDisbursementDate(),
                loanBO.getGracePeriodDuration(), loanBO.getBusinessActivityId(), "Loan account updated", null,
                null, false, null, null);

        Map<String, String> fees1 = new HashMap<String, String>();
        fees1.put("Mainatnence Fee", "100.0");

        LoanScheduleEntity[] paymentsArray = LoanBOTestUtils
                .getSortedAccountActionDateEntity(loanBO.getAccountActionDates());

        List<Date> installmentDates = new ArrayList<Date>();
        List<Date> feeDates = new ArrayList<Date>();
        for (LoanScheduleEntity loanScheduleEntity : paymentsArray) {
            installmentDates.add(loanScheduleEntity.getActionDate());
            for (AccountFeesActionDetailEntity accountFeesActionDetailEntity : loanScheduleEntity
                    .getAccountFeesActionDetails()) {
                Date feeDate = accountFeesActionDetailEntity.getAccountActionDate().getActionDate();
                feeDates.add(feeDate);
            }
        }
        System.out.println(installmentDates);
        System.out.println(feeDates);

        Assert.assertEquals(6, paymentsArray.length);

        checkFees(fees1, paymentsArray[0], false);
        checkFees(fees1, paymentsArray[1], false);
        checkFees(fees1, paymentsArray[2], false);
        checkFees(fees1, paymentsArray[3], false);
        checkFees(fees1, paymentsArray[4], false);
        checkFees(fees1, paymentsArray[5], false);

        List<Date> expectedDates = new ArrayList<Date>();
        expectedDates.add(DateUtils.getDate(2008, Calendar.MAY, 31));
        expectedDates.add(DateUtils.getDate(2008, Calendar.JUNE, 06));
        expectedDates.add(DateUtils.getDate(2008, Calendar.JUNE, 13));
        expectedDates.add(DateUtils.getDate(2008, Calendar.JUNE, 20));
        expectedDates.add(DateUtils.getDate(2008, Calendar.JUNE, 27));
        expectedDates.add(DateUtils.getDate(2008, Calendar.JULY, 04));

        int i = 0;
        for (AccountActionDateEntity accountActionDateEntity : accountBO.getAccountActionDates()) {
            LoanScheduleEntity loanScheduleEntity = (LoanScheduleEntity) accountActionDateEntity;
            Assert.assertEquals(expectedDates.get(i++), loanScheduleEntity.getActionDate());
            Assert.assertEquals(new Money(getCurrency(), "100"), loanScheduleEntity.getTotalFees());
        }

        Assert.assertEquals(intialTotalFeeAmount.add(new Money(getCurrency(), "600.0")),
                loanBO.getLoanSummary().getOriginalFees());
    } finally {
        // make sure that we don't leave any persistent changes that could
        // affect subsequent tests
        new DateTimeService().resetToCurrentSystemDateTime();
        deleteHoliday(holiday);
    }
}