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:com.autentia.tnt.manager.holiday.UserHolidaysStateManager.java

public UserHolidaysState calcUserHolidaysState(User usuario, Date chargeYear) {
    UserHolidaysState uhs = new UserHolidaysState();
    uhs.setUser(usuario);//www. java  2s . co  m
    // WorkingAgreement attribute is an HB proxy not initialized, we need to get it from DB
    WorkingAgreementDAO workingAgreementDao = WorkingAgreementDAO.getDefault();
    WorkingAgreement agreement = workingAgreementDao.getById(usuario.getAgreement().getId());
    // and refresh the user instance agreement attribute
    usuario.setAgreement(agreement);

    uhs.setTotalYear(agreement.getHolidays());

    int acceptedHolidays = 0;

    if (chargeYear != null) {

        HolidayManager fiestasManager = HolidayManager.getDefault();

        // We must take in account previous year holidays and next year holidays

        Calendar calMin = Calendar.getInstance();
        calMin.setTime(chargeYear);
        calMin.set(Calendar.MONTH, calMin.getMinimum(Calendar.MONTH));
        calMin.set(Calendar.DAY_OF_MONTH, calMin.getMinimum(Calendar.DAY_OF_MONTH));
        calMin.set(Calendar.HOUR_OF_DAY, calMin.getMinimum(Calendar.HOUR_OF_DAY));
        calMin.set(Calendar.MINUTE, calMin.getMinimum(Calendar.MINUTE));
        calMin.set(Calendar.SECOND, calMin.getMinimum(Calendar.SECOND));
        calMin.set(Calendar.MILLISECOND, calMin.getMinimum(Calendar.MILLISECOND));

        Calendar calMax = Calendar.getInstance();
        calMax.setTime(chargeYear);
        calMax.set(Calendar.MONTH, calMax.getMaximum(Calendar.MONTH));
        calMax.set(Calendar.DAY_OF_MONTH, calMax.getMaximum(Calendar.DAY_OF_MONTH));
        calMax.set(Calendar.HOUR_OF_DAY, calMax.getMaximum(Calendar.HOUR_OF_DAY));
        calMax.set(Calendar.MINUTE, calMax.getMaximum(Calendar.MINUTE));
        calMax.set(Calendar.SECOND, calMax.getMaximum(Calendar.SECOND));
        calMax.set(Calendar.MILLISECOND, calMax.getMaximum(Calendar.MILLISECOND));

        calMin.add(Calendar.YEAR, -1);
        calMax.add(Calendar.YEAR, 1);

        HolidaySearch fiestaSearch = new HolidaySearch();
        fiestaSearch.setStartDate(calMin.getTime());
        fiestaSearch.setEndDate(calMax.getTime());

        List<Holiday> listFiestas = fiestasManager.getAllEntities(fiestaSearch, null);

        calMin.setTime(chargeYear);
        calMin.set(Calendar.MONTH, calMin.getMinimum(Calendar.MONTH));
        calMin.set(Calendar.DAY_OF_MONTH, calMin.getMinimum(Calendar.DAY_OF_MONTH));
        calMin.set(Calendar.HOUR_OF_DAY, calMin.getMinimum(Calendar.HOUR_OF_DAY));
        calMin.set(Calendar.MINUTE, calMin.getMinimum(Calendar.MINUTE));
        calMin.set(Calendar.SECOND, calMin.getMinimum(Calendar.SECOND));
        calMin.set(Calendar.MILLISECOND, calMin.getMinimum(Calendar.MILLISECOND));

        calMax.setTime(chargeYear);
        calMax.set(Calendar.MONTH, calMax.getMaximum(Calendar.MONTH));
        calMax.set(Calendar.DAY_OF_MONTH, calMax.getMaximum(Calendar.DAY_OF_MONTH));
        calMax.set(Calendar.HOUR_OF_DAY, calMax.getMaximum(Calendar.HOUR_OF_DAY));
        calMax.set(Calendar.MINUTE, calMax.getMaximum(Calendar.MINUTE));
        calMax.set(Calendar.SECOND, calMax.getMaximum(Calendar.SECOND));
        calMax.set(Calendar.MILLISECOND, calMax.getMaximum(Calendar.MILLISECOND));

        RequestHolidayManager holyManager = RequestHolidayManager.getDefault();
        RequestHolidaySearch holSearch = new RequestHolidaySearch();
        holSearch.setUserRequest(uhs.getUser());
        holSearch.setState(HolidayState.ACCEPT);
        holSearch.setStartChargeYear(calMin.getTime());
        holSearch.setEndChargeYear(calMax.getTime());

        List<RequestHoliday> listH = holyManager.getAllEntities(holSearch, null);

        for (RequestHoliday rH : listH) {
            Calendar cActual = Calendar.getInstance();
            cActual.setTime(rH.getBeginDate());
            while (!cActual.getTime().after(rH.getFinalDate())) {
                if (cActual.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY
                        && cActual.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) {
                    boolean isFiesta = false;

                    for (Holiday fiest : listFiestas) {
                        Calendar cFiesta = Calendar.getInstance();
                        cFiesta.setTime(fiest.getDate());
                        if (cFiesta.get(Calendar.YEAR) == cActual.get(Calendar.YEAR)
                                && cFiesta.get(Calendar.MONTH) == cActual.get(Calendar.MONTH)
                                && cFiesta.get(Calendar.DAY_OF_MONTH) == cActual.get(Calendar.DAY_OF_MONTH)) {
                            isFiesta = true;
                        }
                    }

                    if (!isFiesta) {
                        acceptedHolidays++;
                    }
                }

                cActual.add(Calendar.DAY_OF_MONTH, 1);
            }

        }
        uhs.setTotalAccepted(acceptedHolidays);

        Calendar calAuxCont = Calendar.getInstance();
        calAuxCont.setTime(uhs.getUser().getStartDate());

        Calendar calAux = Calendar.getInstance();
        calAux.setTime(chargeYear);
        int yearCharge = calAux.get(Calendar.YEAR);
        int yearContract = calAuxCont.get(Calendar.YEAR);

        if (yearCharge == yearContract) {
            // Dividimos los das de cada usuario entre los meses del ao.
            double ratio = uhs.getUser().getAgreement().getHolidays() / 12.0;
            int monthContract = calAuxCont.get(Calendar.MONTH);
            int meses = (Calendar.DECEMBER - monthContract);
            double diasVacaciones = meses * ratio;
            double aux = Math.ceil(diasVacaciones);
            uhs.setTotalYear((int) aux);
        }
    }

    return uhs;
}

From source file:helper.lang.DateHelperTest.java

@Test
public void testDiffAndConversionsSameDate() {
    Calendar cal1 = new GregorianCalendar(1998, Calendar.DECEMBER, 25, 2, 2);
    Calendar cal2 = new GregorianCalendar(1998, Calendar.DECEMBER, 25, 3, 3);
    long diffMillis = DateHelper.diffInMillis(cal1.getTimeInMillis(), cal2.getTimeInMillis());

    assertEquals(3660000, diffMillis);//from  w  w w  .java 2s .  co m
    assertEquals(3660, DateHelper.millisToSeconds(diffMillis));
    assertEquals(61, DateHelper.millisToMinutes(diffMillis));
    assertEquals(1, DateHelper.millisToHours(diffMillis));
    assertEquals(0, DateHelper.millisToDays(diffMillis));
}

From source file:com.wxxr.nirvana.json.JSONResultTest.java

@SuppressWarnings("unchecked")
public void test() throws Exception {
    JSONResult result = new JSONResult();

    TestAction action = new TestAction();
    stack.push(action);/*from www .j av a  2 s  .  c o m*/

    // test scape characters
    action.setArray(new String[] { "a", "a", "\"", "\\", "/", "\b", "\f", "\n", "\r", "\t" });

    List list = new ArrayList();

    list.add("b");
    list.add(1);
    list.add(new int[] { 10, 12 });
    action.setCollection(list);

    // beans
    List collection2 = new ArrayList();
    Bean bean1 = new Bean();

    bean1.setBigDecimal(new BigDecimal("111111.111111"));
    bean1.setBigInteger(new BigInteger("111111111111"));
    bean1.setStringField("str");
    bean1.setBooleanField(true);
    bean1.setCharField('s');
    bean1.setDoubleField(10.1);
    bean1.setFloatField(1.5f);
    bean1.setIntField(10);
    bean1.setLongField(100);
    bean1.setEnumField(AnEnum.ValueA);
    bean1.setEnumBean(AnEnumBean.One);

    Bean bean2 = new Bean();

    bean2.setStringField("  ");
    bean2.setBooleanField(false);
    bean2.setFloatField(1.1f);
    bean2.setDoubleField(2.2);
    bean2.setEnumField(AnEnum.ValueB);
    bean2.setEnumBean(AnEnumBean.Two);

    // circular reference
    bean1.setObjectField(bean2);
    bean2.setObjectField(bean1);

    collection2.add(bean1);
    action.setCollection2(collection2);

    // keep order in map
    Map map = new LinkedHashMap();

    map.put("a", 1);
    map.put("c", new float[] { 1.0f, 2.0f });
    action.setMap(map);

    action.setFoo("foo");
    // should be ignored, marked 'transient'
    action.setBar("bar");

    // date
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.YEAR, 1999);
    calendar.set(Calendar.MONTH, Calendar.DECEMBER);
    calendar.set(Calendar.DAY_OF_MONTH, 31);
    calendar.set(Calendar.HOUR_OF_DAY, 11);
    calendar.set(Calendar.MINUTE, 59);
    calendar.set(Calendar.SECOND, 59);
    action.setDate(calendar.getTime());
    action.setDate2(calendar.getTime());

    this.invocation.setAction(action);
    result.execute(this.invocation);

    String json = response.getContentAsString();

    String normalizedActual = TestUtils.normalize(json, true);
    String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("json.txt"));
    assertEquals(normalizedExpected, normalizedActual);
    assertEquals("application/json;charset=ISO-8859-1", response.getContentType());
}

From source file:org.kuali.kfs.module.endow.businessobject.lookup.CalculateProcessDateUsingFrequencyCodeService.java

/**
 * This method will check the current month and set the calendar to that month
 * @param month month to set the calendar
 * @return calendar calendar is set to the month selected
 *//*w ww.j  a v a2 s.  c  om*/
protected Calendar setCaledarWithMonth(String month, Date currentDate) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(currentDate);
    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:edu.stanford.muse.email.CalendarUtil.java

/** cool method to convert a pair of <yy, mm, dd> specs per Gregorian calendar to a date range.
 * Note: startM, endM are 0-based, startD, endD are 1-based.
 * startY/endY must be valid (>= 0), otherwise a null is returned for start / end dates.
 * Note: all months are 0-based, but days-of-month start from 1.
 * startM/endM/startD/endD can be invalid (< 0, or also > 11 in the case of months) in which case they are treated as "*".
 * i.e. put to their min values for start, or to max values for end.
 * if startM is invalid, startD is ignored and also considered invalid. likewise for endM/endD.
 * no handling of time zone, default TZ is assumed.
 * *//*w w w  .ja  v  a2  s .co m*/
public static Pair<Date, Date> getDateRange(int startY, int startM, int startD, int endY, int endM, int endD) {
    Date startDate = null;
    // Calendar.JANUARY is 0, and Calendar.DECEMBER is 11
    if (startY >= 0) {
        // check startM
        if (startM < Calendar.JANUARY || startM > Calendar.DECEMBER) {
            // invalid startM, assign M and D to Jan 1
            startM = Calendar.JANUARY;
            startD = 1;
        } else {
            if (startD <= 0) // invalid startD
                startD = 1;
        }
        startDate = convertYYMMDDToDate(startY, startM, startD, true);
    }

    // endM/endD will be set to be BEYOND the end of the desired day/month/year.
    // e.g. if the end y/m/d params are 2001/-1/<whatever>, we want end y/m/d to correspond to 2002 1st Jan
    // and we'll compute endDate back to EOD 2001 31st Dec.
    // if the end y/m/d params are 2001/5/-1, we want y/m/d to become correspond to 2001, 1st June and we'll set endDate back to
    // EOD on 2001, 31st May.
    Date endDate = null;

    if (endY >= 0) {
        if (endM < Calendar.JANUARY || endM > Calendar.DECEMBER) {
            // invalid endM (and endD), therefore set to end
            endM = Calendar.JANUARY;
            endD = 1;
            endY++;
        } else {
            if (endD <= 0) {
                // no date provided, so just bump month.
                endD = 1;
                endM++;
                if (endM > Calendar.DECEMBER) {
                    // obviously account for rollovers. so 2001/11/-1 sets end y/m/d to 2002/0/1
                    endY++;
                    endM = Calendar.JANUARY;
                }
            } else {
                endD++;
                // bump day, but need to check if its more than the allowed days for that month. misery!
                // http://stackoverflow.com/questions/8940438/number-of-days-in-particular-month-of-particular-year
                Calendar tmp = new GregorianCalendar(endY, endM, 1);
                int maxDays = tmp.getActualMaximum(Calendar.DAY_OF_MONTH);
                if (endD > maxDays) {
                    endD = 1;
                    // bump month
                    endM++;
                    if (endM > Calendar.DECEMBER) {
                        // obviously account for rollovers. so 2001/11/-1 sets end y/m/d to 2002/0/1
                        endY++;
                        endM = Calendar.JANUARY;
                    }
                }
            }
        }
        Date beyond_end = convertYYMMDDToDate(endY, endM, endD, true);
        endDate = new Date(beyond_end.getTime() - 1001L);
    }

    log.info("date range: " + startDate + "-" + endDate);
    return new Pair<Date, Date>(startDate, endDate);
}

From source file:com.swiftcorp.portal.common.util.CalendarUtils.java

@Deprecated
public static Calendar addMonthDayToCal(Calendar cal, int month, int day) {
    Date d = new Date();
    int daysToAdd = 0;
    // Calendar cal = Calendar.getInstance();
    int currentMonth = cal.get(2);
    long t = 0;//from w ww  .  ja va 2 s.  com

    t = d.getTime();
    if (month > 0) {
        // cal.get ( month );
        for (int i = 0; i < month; i++) {
            if (currentMonth < 12) {
                if (currentMonth == Calendar.JANUARY) {
                    cal.set(2, Calendar.JANUARY);
                    daysToAdd += cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                } else if (currentMonth == Calendar.FEBRUARY) {
                    cal.set(2, Calendar.FEBRUARY);
                    daysToAdd += cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                } else if (currentMonth == Calendar.MARCH) {
                    cal.set(2, Calendar.MARCH);
                    daysToAdd += cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                } else if (currentMonth == Calendar.APRIL) {
                    cal.set(2, Calendar.APRIL);
                    daysToAdd += cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                } else if (currentMonth == Calendar.MAY) {
                    cal.set(2, Calendar.MAY);
                    daysToAdd += cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                } else if (currentMonth == Calendar.JUNE) {
                    cal.set(2, Calendar.JUNE);
                    daysToAdd += cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                } else if (currentMonth == Calendar.JULY) {
                    cal.set(2, Calendar.JULY);
                    daysToAdd += cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                } else if (currentMonth == Calendar.AUGUST) {
                    cal.set(2, Calendar.AUGUST);
                    daysToAdd += cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                } else if (currentMonth == Calendar.SEPTEMBER) {
                    cal.set(2, Calendar.SEPTEMBER);
                    daysToAdd += cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                } else if (currentMonth == Calendar.OCTOBER) {
                    cal.set(2, Calendar.OCTOBER);
                    daysToAdd += cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                } else if (currentMonth == Calendar.NOVEMBER) {
                    cal.set(2, Calendar.NOVEMBER);
                    daysToAdd += cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                } else if (currentMonth == Calendar.DECEMBER) {
                    cal.set(2, Calendar.DECEMBER);
                    daysToAdd += cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                }
                currentMonth++;
            } else {
                currentMonth = 0;
                i--;
            }
        }
    }
    daysToAdd += day;
    // add the desired number of days to the long value using milli seconds

    t += daysToAdd * MILLIS_PER_DAY;
    cal.setTime(new Date(t));
    // and now you can format the date the way you want
    String result = Integer.toString(cal.get(Calendar.DAY_OF_MONTH)) + "-"
            + Integer.toString(cal.get(Calendar.MONTH) + 1) + "-" + Integer.toString(cal.get(Calendar.YEAR));
    System.out.println("result month add::" + result);
    return cal;
}

From source file:se.technipelago.weather.chart.Generator.java

public String[] generateYearlyCharts(int year) {

    init();/*www.  j a  va 2  s . c om*/

    List<String> files = new ArrayList<String>();
    try {
        // Historical data.
        Calendar cal = Calendar.getInstance();
        int currentYear = cal.get(Calendar.YEAR);
        int currentMonth = cal.get(Calendar.MONTH);
        cal.set(Calendar.YEAR, year);
        cal.set(Calendar.MILLISECOND, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.DAY_OF_MONTH, 1);
        cal.set(Calendar.MONTH, Calendar.JANUARY);
        Date start = cal.getTime();
        if (year < currentYear) {
            cal.set(Calendar.MONTH, Calendar.DECEMBER);
        } else {
            cal.set(Calendar.MONTH, currentMonth);
        }
        cal.add(Calendar.MONTH, 1);
        cal.add(Calendar.MILLISECOND, -1);
        Date stop = cal.getTime();
        Timespan period = new Timespan(start, stop);
        createHistoryChart(period, "temp_out", "Temperatur", "\u00B0Celcius", "temperature_" + year + ".png");
        files.add("temperature_" + year + ".png");
        createHistoryChart(period, "barometer", "Barometer", "Millibar", "barometer_" + year + ".png");
        files.add("barometer_" + year + ".png");
        createHistoryChart(period, "hum_out", "Luftfuktighet", "Procent", "humidity_" + year + ".png");
        files.add("humidity_" + year + ".png");
        createHistoryChart(period, "wind_avg", "Vindhastighet", "m/s", "wind_" + year + ".png");
        files.add("wind_" + year + ".png");
        createHistoryChart(period, "solar", "Solstr\u00e5lning", "W/m\u00B2", "solar_" + year + ".png");
        files.add("solar_" + year + ".png");
        createHistoryChart(period, "uv", "UV-index", "UV", "uv_" + year + ".png");
        files.add("uv_" + year + ".png");
        createRainHistoryChart(period, "rain_" + year + ".png");
        files.add("rain_" + year + ".png");
    } catch (IOException e) {
        log.log(Level.SEVERE, "I/O Error", e);
    }
    return files.toArray(new String[files.size()]);
}

From source file:com.gemstone.gemfire.rest.internal.web.controllers.RestAPIsAndInterOpsDUnitTest.java

public static void doPutsInClientCache() {
    ClientCache cache = GemFireCacheImpl.getInstance();
    assertNotNull(cache);//  w w w  . ja v  a2 s.  com
    Region<String, Object> region = cache.getRegion(PEOPLE_REGION_NAME);

    //put person object
    final Person person1 = new Person(101L, "Mithali", "Dorai", "Raj",
            DateTimeUtils.createDate(1982, Calendar.DECEMBER, 4), Gender.FEMALE);
    final Person person2 = new Person(102L, "Sachin", "Ramesh", "Tendulkar",
            DateTimeUtils.createDate(1975, Calendar.DECEMBER, 14), Gender.MALE);
    final Person person3 = new Person(103L, "Saurabh", "Baburav", "Ganguly",
            DateTimeUtils.createDate(1972, Calendar.AUGUST, 29), Gender.MALE);
    final Person person4 = new Person(104L, "Rahul", "subrymanyam", "Dravid",
            DateTimeUtils.createDate(1979, Calendar.MARCH, 17), Gender.MALE);
    final Person person5 = new Person(105L, "Jhulan", "Chidambaram", "Goswami",
            DateTimeUtils.createDate(1983, Calendar.NOVEMBER, 25), Gender.FEMALE);

    region.put("1", person1);
    region.put("2", person2);
    region.put("3", person3);
    region.put("4", person4);
    region.put("5", person5);

    final Person person6 = new Person(101L, "Rahul", "Rajiv", "Gndhi",
            DateTimeUtils.createDate(1970, Calendar.MAY, 14), Gender.MALE);
    final Person person7 = new Person(102L, "Narendra", "Damodar", "Modi",
            DateTimeUtils.createDate(1945, Calendar.DECEMBER, 24), Gender.MALE);
    final Person person8 = new Person(103L, "Atal", "Bihari", "Vajpayee",
            DateTimeUtils.createDate(1920, Calendar.AUGUST, 9), Gender.MALE);
    final Person person9 = new Person(104L, "Soniya", "Rajiv", "Gandhi",
            DateTimeUtils.createDate(1929, Calendar.MARCH, 27), Gender.FEMALE);
    final Person person10 = new Person(104L, "Priyanka", "Robert", "Gandhi",
            DateTimeUtils.createDate(1973, Calendar.APRIL, 15), Gender.FEMALE);

    final Person person11 = new Person(104L, "Murali", "Manohar", "Joshi",
            DateTimeUtils.createDate(1923, Calendar.APRIL, 25), Gender.MALE);
    final Person person12 = new Person(104L, "Lalkrishna", "Parmhansh", "Advani",
            DateTimeUtils.createDate(1910, Calendar.JANUARY, 01), Gender.MALE);
    final Person person13 = new Person(104L, "Shushma", "kumari", "Swaraj",
            DateTimeUtils.createDate(1943, Calendar.AUGUST, 10), Gender.FEMALE);
    final Person person14 = new Person(104L, "Arun", "raman", "jetly",
            DateTimeUtils.createDate(1942, Calendar.OCTOBER, 27), Gender.MALE);
    final Person person15 = new Person(104L, "Amit", "kumar", "shah",
            DateTimeUtils.createDate(1958, Calendar.DECEMBER, 21), Gender.MALE);
    final Person person16 = new Person(104L, "Shila", "kumari", "Dixit",
            DateTimeUtils.createDate(1927, Calendar.FEBRUARY, 15), Gender.FEMALE);

    Map<String, Object> userMap = new HashMap<String, Object>();
    userMap.put("6", person6);
    userMap.put("7", person7);
    userMap.put("8", person8);
    userMap.put("9", person9);
    userMap.put("10", person10);
    userMap.put("11", person11);
    userMap.put("12", person12);
    userMap.put("13", person13);
    userMap.put("14", person14);
    userMap.put("15", person15);
    userMap.put("16", person16);

    region.putAll(userMap);

    if (cache != null)
        cache.getLogger().info("Gemfire Cache Client: Puts successfully done");

}

From source file:com.feilong.commons.core.date.DateUtil.java

/**
 * ? <code>23:59:59.999</code> <br>
 * //from ww  w  .  j  a v  a 2  s.  c  o m
 * <pre>
 *   2012-10-11 17:10:30.701,
 * 
 * return 2012-12-31 23:59:59.999
 * </pre>
 * 
 * @param date
 *            ?date
 * @return Date
 * @see #toCalendar(Date)
 * @see Calendar#set(int, int)
 * @see #dayEnd(Calendar)
 * @see Calendar#getTime()
 * @since 1.0
 */
public static final Date getLastDateOfThisYear(Date date) {
    Calendar calendar = toCalendar(date);
    calendar.set(Calendar.MONTH, Calendar.DECEMBER);
    calendar.set(Calendar.DAY_OF_MONTH, 31);
    dayEnd(calendar);
    return calendar.getTime();
}

From source file:com.stratelia.webactiv.util.DateUtilTest.java

@Test
public void testGetEndDateOfYear() {
    Date dateTest = DateUtil.getEndDateOfYear(java.sql.Date.valueOf("2013-04-20"));
    Calendar cal = DateUtil.convert(dateTest);
    assertThat(cal.get(Calendar.YEAR), is(2013));
    assertThat(cal.get(Calendar.MONTH), is(Calendar.DECEMBER));
    assertThat(cal.get(Calendar.DAY_OF_MONTH), is(31));
    assertThat(cal.get(Calendar.HOUR_OF_DAY), is(23));
    assertThat(cal.get(Calendar.MINUTE), is(59));
    assertThat(cal.get(Calendar.SECOND), is(59));
    assertThat(cal.get(Calendar.MILLISECOND), is(999));
}