Example usage for java.util Calendar JANUARY

List of usage examples for java.util Calendar JANUARY

Introduction

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

Prototype

int JANUARY

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

Click Source Link

Document

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

Usage

From source file:br.ojimarcius.commons.util.AbstractDateUtils.java

protected static Collection<Calendar> getBrasilianHolidays(final int year) {
    Collection<Calendar> holidays = new ArrayList<Calendar>();

    // feriados fixos
    holidays.add(new GregorianCalendar(year, Calendar.JANUARY, 1)); // Confraternizacao Universal
    holidays.add(new GregorianCalendar(year, Calendar.APRIL, 21)); // Tiradentes
    holidays.add(new GregorianCalendar(year, Calendar.MAY, 1)); // Dia do Trabalho
    holidays.add(new GregorianCalendar(year, Calendar.OCTOBER, 12)); // Nossa Senhora Aparecida
    holidays.add(new GregorianCalendar(year, Calendar.NOVEMBER, 2)); // Finados
    holidays.add(new GregorianCalendar(year, Calendar.NOVEMBER, 15)); // Proclamacao da Republica
    holidays.add(new GregorianCalendar(year, Calendar.DECEMBER, 25)); // Natal

    // feriados calculados
    Calendar pascoa = getSundayOfEaster(year);
    Calendar carnaval = (Calendar) pascoa.clone();
    carnaval.add(Calendar.DAY_OF_MONTH, -47);
    Calendar corpusChristi = (Calendar) pascoa.clone();
    corpusChristi.add(Calendar.DAY_OF_MONTH, 60);

    holidays.add(carnaval); // Carnaval
    holidays.add(pascoa); // Pascoa
    holidays.add(corpusChristi); // Corpus Christi

    return holidays;
}

From source file:org.mifos.customers.client.persistence.ClientPersistenceIntegrationTest.java

private ClientBO createClosedClientWithGovtId() {
    return createClosedClient(this.getClass().getSimpleName() + " Closed Client",
            DateUtils.getDate(1983, Calendar.JANUARY, 1), GOVT_ID);
}

From source file:com.evolveum.midpoint.report.BasicReportTest.java

private Calendar create_2014_01_01_12_00_Calendar() {
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.YEAR, 2014);
    calendar.set(Calendar.MONTH, Calendar.JANUARY);
    calendar.set(Calendar.DAY_OF_MONTH, 1);
    calendar.set(Calendar.HOUR_OF_DAY, 12);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    calendar.set(Calendar.MILLISECOND, 0);

    return calendar;
}

From source file:org.mifos.reports.branchreport.persistence.BranchReportPersistenceIntegrationTest.java

@Override
@Before/*from  ww  w  .  ja  va 2 s .c  om*/
public void setUp() throws Exception {
    super.setUp();
    branchReportPersistence = new BranchReportPersistence();
    runDate = DateUtils.getDate(2008, Calendar.JANUARY, 1);
    branchReportWithLoanArrears = new BranchReportBO(BRANCH_ID, runDate);
    branchReportWithLoanArrears
            .addLoanArrearsAging(new BranchReportLoanArrearsAgingBO(LoanArrearsAgingPeriod.ONE_WEEK));

    branchReportWithClientSummaries = new BranchReportBO(BRANCH_ID, runDate);
    branchReportWithClientSummaries.addClientSummary(
            BranchReportBOFixture.createBranchReportClientSummaryBO(BranchReportClientSummaryBO.CENTER_COUNT));

    branchReportWithStaffSummary = new BranchReportBO(BRANCH_ID, runDate);
    branchReportWithStaffSummary.addStaffSummary(BranchReportBOFixture.createBranchReportStaffSummaryBO());

    session = StaticHibernateUtil.getSessionTL();
}

From source file:org.openmrs.module.radiology.web.controller.PortletsControllerTest.java

/**
 * @see PortletsController#isEndDateBeforeStartDate(Date, Date)
 * @verifies return false with given start date but end date null
 *//*from   w  w  w. java  2 s .c  om*/
@Test
public void isEndDateBeforeStartDate_shouldReturnFalsewithGivenStartDateButEndDateNull() throws Exception {

    Method isEndDateBeforeStartDateMethod = portletsController.getClass().getDeclaredMethod(
            "isEndDateBeforeStartDate", new Class[] { java.util.Date.class, java.util.Date.class });
    isEndDateBeforeStartDateMethod.setAccessible(true);

    Date startDate = new GregorianCalendar(2001, Calendar.JANUARY, 01).getTime();
    Date endDate = null;

    Boolean isEndDateBeforeStartDate = (Boolean) isEndDateBeforeStartDateMethod.invoke(portletsController,
            new Object[] { startDate, endDate });
    assertThat(isEndDateBeforeStartDate, is(false));
}

From source file:adalid.commons.util.TimeUtils.java

public static Time newTime(int hourOfDay, int minuteOfHour, int secondOfMinute) {
    Calendar c = Calendar.getInstance();
    c.set(Calendar.YEAR, 1970);/*from   w w w .java  2 s . com*/
    c.set(Calendar.MONTH, Calendar.JANUARY);
    c.set(Calendar.DAY_OF_MONTH, 1);
    c.set(Calendar.HOUR_OF_DAY, hourOfDay);
    c.set(Calendar.MINUTE, minuteOfHour);
    c.set(Calendar.SECOND, secondOfMinute);
    c.set(Calendar.MILLISECOND, 0);
    return new Time(c.getTimeInMillis());
}

From source file:agency.AgencyManagerImplTest.java

private static Mission newMission01() {
    Calendar missionBegin = new GregorianCalendar(2015, Calendar.JANUARY, 1);
    Calendar missionEnd = new GregorianCalendar(2015, Calendar.MARCH, 11);

    return newMission("The Avengers", missionBegin.getTime(), missionEnd.getTime(), 3, 3, "code name - PV168");
}

From source file:Time.java

/**
 * Return true if the specified year is a leap year.
 * //from   ww w . j  a  v a 2  s.  c  o  m
 * @param year
 *          Year to check.
 * @return True if specified year is leap year, false otherwise.
 */
public static boolean isLeapYear(int year) {
    return (new Day(year, Calendar.JANUARY, 1)).isLeapYear();
}

From source file:edu.jhuapl.graphs.jfreechart.JFreeChartTimeSeriesGraphSource.java

private static Date getKernelDate(Date d, TimeResolution resolution) {
    Calendar c = Calendar.getInstance();
    c.setTime(d);//from   w w w .  j av  a2  s .co m

    switch (resolution) {
    case HOURLY:
        c.set(Calendar.MINUTE, 0);
        c.set(Calendar.SECOND, 0);
        c.set(Calendar.MILLISECOND, 0);
        break;
    case DAILY:
        c.set(Calendar.HOUR_OF_DAY, 0);
        c.set(Calendar.MINUTE, 0);
        c.set(Calendar.SECOND, 0);
        c.set(Calendar.MILLISECOND, 0);
        break;
    case WEEKLY:
        c.set(Calendar.DAY_OF_WEEK, 1);
        c.set(Calendar.HOUR_OF_DAY, 0);
        c.set(Calendar.MINUTE, 0);
        c.set(Calendar.SECOND, 0);
        c.set(Calendar.MILLISECOND, 0);
        break;
    case MONTHLY:
        c.set(Calendar.WEEK_OF_MONTH, 1);
        c.set(Calendar.DAY_OF_WEEK, 1);
        c.set(Calendar.HOUR_OF_DAY, 0);
        c.set(Calendar.MINUTE, 0);
        c.set(Calendar.SECOND, 0);
        c.set(Calendar.MILLISECOND, 0);
        break;
    case QUARTERLY:
        int numMonthsInQuarter = 3;
        // sets to either January 1st, April 1st, July 1st or October 1st
        c.set(Calendar.MONTH, c.get(Calendar.MONTH) / numMonthsInQuarter * numMonthsInQuarter);
        c.set(Calendar.DAY_OF_MONTH, 1);
        c.set(Calendar.HOUR_OF_DAY, 0);
        c.set(Calendar.MINUTE, 0);
        c.set(Calendar.SECOND, 0);
        c.set(Calendar.MILLISECOND, 0);
        break;
    case YEARLY:
        c.set(Calendar.MONTH, Calendar.JANUARY);
        c.set(Calendar.WEEK_OF_MONTH, 1);
        c.set(Calendar.DAY_OF_WEEK, 1);
        c.set(Calendar.HOUR_OF_DAY, 0);
        c.set(Calendar.MINUTE, 0);
        c.set(Calendar.SECOND, 0);
        c.set(Calendar.MILLISECOND, 0);
        break;
    }

    return c.getTime();
}

From source file:org.openmrs.module.radiology.web.controller.RadiologyOrderFormControllerTest.java

/**
 * @see RadiologyOrderFormController#postDiscontinueRadiologyOrder(HttpServletRequest,
 *      HttpServletResponse, Order, String, Date)
 *///from   www .j  ava 2 s. c  o m
@Test
@Verifies(value = "should discontinue non discontinued order and redirect to discontinuation order", method = "postDiscontinueRadiologyOrder(HttpServletRequest, HttpServletResponse, Order, String, Date)")
public void postDiscontinueRadiologyOrder_shouldDiscontinueNonDiscontinuedOrderAndRedirectToDiscontinuationOrder()
        throws Exception {
    //given
    RadiologyOrder mockRadiologyOrderToDiscontinue = RadiologyTestData.getMockRadiologyOrder1();
    mockRadiologyOrderToDiscontinue.getStudy().setMwlStatus(MwlStatus.DISCONTINUE_OK);
    String discontinueReason = "Wrong Procedure";
    Date discontinueDate = new GregorianCalendar(2015, Calendar.JANUARY, 01).getTime();

    Order mockDiscontinuationOrder = new Order();
    mockDiscontinuationOrder.setOrderId(2);
    mockDiscontinuationOrder.setAction(Order.Action.DISCONTINUE);
    mockDiscontinuationOrder.setOrderer(mockRadiologyOrderToDiscontinue.getOrderer());
    mockDiscontinuationOrder.setOrderReasonNonCoded(discontinueReason);
    mockDiscontinuationOrder.setDateActivated(discontinueDate);
    mockDiscontinuationOrder.setPreviousOrder(mockRadiologyOrderToDiscontinue);

    MockHttpServletRequest mockRequest = new MockHttpServletRequest();
    mockRequest.addParameter("discontinueOrder", "discontinueOrder");
    MockHttpSession mockSession = new MockHttpSession();
    mockRequest.setSession(mockSession);

    when(radiologyService.getRadiologyOrderByOrderId(mockRadiologyOrderToDiscontinue.getOrderId()))
            .thenReturn(mockRadiologyOrderToDiscontinue);
    when(radiologyService.discontinueRadiologyOrder(mockRadiologyOrderToDiscontinue,
            mockDiscontinuationOrder.getOrderer(), mockDiscontinuationOrder.getDateActivated(),
            mockDiscontinuationOrder.getOrderReasonNonCoded())).thenReturn(mockDiscontinuationOrder);

    assertThat(mockRadiologyOrderToDiscontinue.getAction(), is(Order.Action.NEW));
    ModelAndView modelAndView = radiologyOrderFormController.postDiscontinueRadiologyOrder(mockRequest, null,
            mockRadiologyOrderToDiscontinue, mockDiscontinuationOrder);

    assertNotNull(modelAndView);
    assertThat(modelAndView.getViewName(), is(
            "redirect:/module/radiology/radiologyOrder.form?orderId=" + mockDiscontinuationOrder.getOrderId()));
    assertThat((String) mockSession.getAttribute(WebConstants.OPENMRS_MSG_ATTR),
            is("Order.discontinuedSuccessfully"));
}