List of usage examples for java.util Calendar MAY
int MAY
To view the source code for java.util Calendar MAY.
Click Source Link
From source file:com.mycompany.CRMFly.serviceLayer.ProductsServiceImpl.java
@Transactional public Map<Date, Double> getSumsFotDates(Products product) { Long id = product.getId();/*w ww .j a v a 2 s . c o m*/ 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.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<PositionsInContract> positions = productsDAO.getContractPositionsForProduct(id); HashMap<Date, Double> sums = new HashMap<Date, Double>(); for (PositionsInContract position : positions) { Long posID = position.getId(); Contracts contract = productsDAO.getContractForPosition(posID); Date date = contract.getBegin_date(); if (date.after(beginningOfQuarter)) thisQuarterSum += position.getPrice() * position.getQuantity(); else if (date.after(QuarterBackOne)) QuarterBackOneSum += position.getPrice() * position.getQuantity(); else if (date.after(QuarterBackTwo)) QuarterBackTwoSum += position.getPrice() * position.getQuantity(); else if (date.after(QuarterBackThree)) QuarterBackThreeSum += position.getPrice() * position.getQuantity(); } sums.put(beginningOfQuarter, thisQuarterSum); sums.put(QuarterBackOne, QuarterBackOneSum); sums.put(QuarterBackTwo, QuarterBackTwoSum); sums.put(QuarterBackThree, QuarterBackThreeSum); return sums; }
From source file:com.mb.framework.util.DateTimeUtil.java
/** * This method is used for getting short description of month by the number * of month// www .ja v a 2s .c om * * @param mthNum * @return */ public static String getMonthShortDesc(int mthNum) { String mthShortDesc; switch (mthNum) { case Calendar.JANUARY: { mthShortDesc = DateTimeConstants.SHORT_JANUARY; break; } case Calendar.FEBRUARY: { mthShortDesc = DateTimeConstants.SHORT_FEBRUARY; break; } case Calendar.MARCH: { mthShortDesc = DateTimeConstants.SHORT_MARCH; break; } case Calendar.APRIL: { mthShortDesc = DateTimeConstants.SHORT_APRIL; break; } case Calendar.MAY: { mthShortDesc = DateTimeConstants.SHORT_MAY; break; } case Calendar.JUNE: { mthShortDesc = DateTimeConstants.SHORT_JUNE; break; } case Calendar.JULY: { mthShortDesc = DateTimeConstants.SHORT_JULY; break; } case Calendar.AUGUST: { mthShortDesc = DateTimeConstants.SHORT_AUGUST; break; } case Calendar.SEPTEMBER: { mthShortDesc = DateTimeConstants.SHORT_SEPTEMBER; break; } case Calendar.OCTOBER: { mthShortDesc = DateTimeConstants.SHORT_OCTOBER; break; } case Calendar.NOVEMBER: { mthShortDesc = DateTimeConstants.SHORT_NOVEMBER; break; } case Calendar.DECEMBER: { mthShortDesc = DateTimeConstants.SHORT_DECEMBER; break; } default: { mthShortDesc = ""; break; } } return mthShortDesc; }
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 w w . java2 s. c om*/ }
From source file:com.netflix.simianarmy.basic.BasicCalendar.java
/** * Load holidays.// ww w.j ava 2 s . c o m * * @param year * the year */ protected void loadHolidays(int year) { holidays.clear(); // these aren't all strictly holidays, but days when engineers will likely // not be in the office to respond to rampaging monkeys // new years, or closest work day holidays.add(workDayInYear(year, Calendar.JANUARY, 1)); // 3rd monday == MLK Day holidays.add(dayOfYear(year, Calendar.JANUARY, Calendar.MONDAY, 3)); // 3rd monday == Presidents Day holidays.add(dayOfYear(year, Calendar.FEBRUARY, Calendar.MONDAY, 3)); // last monday == Memorial Day holidays.add(dayOfYear(year, Calendar.MAY, Calendar.MONDAY, -1)); // 4th of July, or closest work day holidays.add(workDayInYear(year, Calendar.JULY, 4)); // first monday == Labor Day holidays.add(dayOfYear(year, Calendar.SEPTEMBER, Calendar.MONDAY, 1)); // second monday == Columbus Day holidays.add(dayOfYear(year, Calendar.OCTOBER, Calendar.MONDAY, 2)); // veterans day, Nov 11th, or closest work day holidays.add(workDayInYear(year, Calendar.NOVEMBER, 11)); // 4th thursday == Thanksgiving holidays.add(dayOfYear(year, Calendar.NOVEMBER, Calendar.THURSDAY, 4)); // 4th friday == "black friday", monkey goes shopping! holidays.add(dayOfYear(year, Calendar.NOVEMBER, Calendar.FRIDAY, 4)); // christmas eve holidays.add(dayOfYear(year, Calendar.DECEMBER, 24)); // christmas day holidays.add(dayOfYear(year, Calendar.DECEMBER, 25)); // day after christmas holidays.add(dayOfYear(year, Calendar.DECEMBER, 26)); // new years eve holidays.add(dayOfYear(year, Calendar.DECEMBER, 31)); // mark the holiday set with the year, so on Jan 1 it will automatically // recalculate the holidays for next year holidays.add(year); }
From source file:com.evolveum.midpoint.task.quartzimpl.CleanupTest.java
private Calendar create_2013_07_12_12_00_Calendar() { Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT+2")); calendar.set(Calendar.YEAR, 2013); calendar.set(Calendar.MONTH, Calendar.MAY); calendar.set(Calendar.DAY_OF_MONTH, 7); 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:netmason.support.graphics.GanttDisplay.java
/** * Creates a sample dataset for a Gantt chart, using sub-tasks. In general, * you won't hard-code the dataset in this way - it's done here so that the * demo is self-contained.// ww w. jav a 2 s. c o m * * @return The dataset. */ private IntervalCategoryDataset createSampleDataset() { final Task t1 = new Task("Write Proposal", date(1, Calendar.APRIL, 2001), date(5, Calendar.APRIL, 2001)); t1.setPercentComplete(1.00); s1.add(t1); final Task t2 = new Task("Obtain Approval", date(9, Calendar.APRIL, 2001), date(9, Calendar.APRIL, 2001)); t2.setPercentComplete(1.00); s1.add(t2); // here is a task split into two subtasks... final Task t3 = new Task("Requirements Analysis", date(10, Calendar.APRIL, 2001), date(5, Calendar.MAY, 2001)); final Task st31 = new Task("Requirements 1", date(10, Calendar.APRIL, 2001), date(25, Calendar.APRIL, 2001)); st31.setPercentComplete(1.0); final Task st32 = new Task("Requirements 2", date(1, Calendar.MAY, 2001), date(5, Calendar.MAY, 2001)); st32.setPercentComplete(1.0); t3.addSubtask(st31); t3.addSubtask(st32); s1.add(t3); // and another... final Task t4 = new Task("Design Phase", date(6, Calendar.MAY, 2001), date(30, Calendar.MAY, 2001)); final Task st41 = new Task("Design 1", date(6, Calendar.MAY, 2001), date(10, Calendar.MAY, 2001)); st41.setPercentComplete(1.0); final Task st42 = new Task("Design 2", date(15, Calendar.MAY, 2001), date(20, Calendar.MAY, 2001)); st42.setPercentComplete(1.0); final Task st43 = new Task("Design 3", date(23, Calendar.MAY, 2001), date(30, Calendar.MAY, 2001)); st43.setPercentComplete(0.50); t4.addSubtask(st41); t4.addSubtask(st42); t4.addSubtask(st43); s1.add(t4); final Task t5 = new Task("Design Signoff", date(2, Calendar.JUNE, 2001), date(2, Calendar.JUNE, 2001)); s1.add(t5); final Task t6 = new Task("Alpha Implementation", date(3, Calendar.JUNE, 2001), date(31, Calendar.JULY, 2001)); t6.setPercentComplete(0.60); s1.add(t6); final Task t7 = new Task("Design Review", date(1, Calendar.AUGUST, 2001), date(8, Calendar.AUGUST, 2001)); t7.setPercentComplete(0.0); s1.add(t7); final Task t8 = new Task("Revised Design Signoff", date(10, Calendar.AUGUST, 2001), date(10, Calendar.AUGUST, 2001)); t8.setPercentComplete(0.0); s1.add(t8); final Task t9 = new Task("Beta Implementation", date(12, Calendar.AUGUST, 2001), date(12, Calendar.SEPTEMBER, 2001)); t9.setPercentComplete(0.0); s1.add(t9); final Task t10 = new Task("Testing", date(13, Calendar.SEPTEMBER, 2001), date(31, Calendar.OCTOBER, 2001)); t10.setPercentComplete(0.0); s1.add(t10); final Task t11 = new Task("Final Implementation", date(1, Calendar.NOVEMBER, 2001), date(15, Calendar.NOVEMBER, 2001)); t11.setPercentComplete(0.0); s1.add(t11); final Task t12 = new Task("Signoff", date(28, Calendar.NOVEMBER, 2001), date(30, Calendar.NOVEMBER, 2001)); t12.setPercentComplete(0.0); s1.add(t12); final TaskSeriesCollection collection = new TaskSeriesCollection(); collection.add(s1); return collection; }
From source file:org.jfree.chart.demo.GanttDemo2.java
/** * Creates a sample dataset for a Gantt chart, using sub-tasks. In general, you won't * hard-code the dataset in this way - it's done here so that the demo is self-contained. * * @return The dataset.//from w ww .j ava2 s. co m */ private IntervalCategoryDataset createSampleDataset() { final TaskSeries s1 = new TaskSeries("Scheduled"); final Task t1 = new Task("Write Proposal", date(1, Calendar.APRIL, 2001), date(5, Calendar.APRIL, 2001)); t1.setPercentComplete(1.00); s1.add(t1); final Task t2 = new Task("Obtain Approval", date(9, Calendar.APRIL, 2001), date(9, Calendar.APRIL, 2001)); t2.setPercentComplete(1.00); s1.add(t2); // here is a task split into two subtasks... final Task t3 = new Task("Requirements Analysis", date(10, Calendar.APRIL, 2001), date(5, Calendar.MAY, 2001)); final Task st31 = new Task("Requirements 1", date(10, Calendar.APRIL, 2001), date(25, Calendar.APRIL, 2001)); st31.setPercentComplete(1.0); final Task st32 = new Task("Requirements 2", date(1, Calendar.MAY, 2001), date(5, Calendar.MAY, 2001)); st32.setPercentComplete(1.0); t3.addSubtask(st31); t3.addSubtask(st32); s1.add(t3); // and another... final Task t4 = new Task("Design Phase", date(6, Calendar.MAY, 2001), date(30, Calendar.MAY, 2001)); final Task st41 = new Task("Design 1", date(6, Calendar.MAY, 2001), date(10, Calendar.MAY, 2001)); st41.setPercentComplete(1.0); final Task st42 = new Task("Design 2", date(15, Calendar.MAY, 2001), date(20, Calendar.MAY, 2001)); st42.setPercentComplete(1.0); final Task st43 = new Task("Design 3", date(23, Calendar.MAY, 2001), date(30, Calendar.MAY, 2001)); st43.setPercentComplete(0.50); t4.addSubtask(st41); t4.addSubtask(st42); t4.addSubtask(st43); s1.add(t4); final Task t5 = new Task("Design Signoff", date(2, Calendar.JUNE, 2001), date(2, Calendar.JUNE, 2001)); s1.add(t5); final Task t6 = new Task("Alpha Implementation", date(3, Calendar.JUNE, 2001), date(31, Calendar.JULY, 2001)); t6.setPercentComplete(0.60); s1.add(t6); final Task t7 = new Task("Design Review", date(1, Calendar.AUGUST, 2001), date(8, Calendar.AUGUST, 2001)); t7.setPercentComplete(0.0); s1.add(t7); final Task t8 = new Task("Revised Design Signoff", date(10, Calendar.AUGUST, 2001), date(10, Calendar.AUGUST, 2001)); t8.setPercentComplete(0.0); s1.add(t8); final Task t9 = new Task("Beta Implementation", date(12, Calendar.AUGUST, 2001), date(12, Calendar.SEPTEMBER, 2001)); t9.setPercentComplete(0.0); s1.add(t9); final Task t10 = new Task("Testing", date(13, Calendar.SEPTEMBER, 2001), date(31, Calendar.OCTOBER, 2001)); t10.setPercentComplete(0.0); s1.add(t10); final Task t11 = new Task("Final Implementation", date(1, Calendar.NOVEMBER, 2001), date(15, Calendar.NOVEMBER, 2001)); t11.setPercentComplete(0.0); s1.add(t11); final Task t12 = new Task("Signoff", date(28, Calendar.NOVEMBER, 2001), date(30, Calendar.NOVEMBER, 2001)); t12.setPercentComplete(0.0); s1.add(t12); final TaskSeriesCollection collection = new TaskSeriesCollection(); collection.add(s1); return collection; }
From source file:org.sakaiproject.util.CalendarUtil.java
void initDates() { Calendar calendarSunday = Calendar.getInstance(); Calendar calendarMonday = Calendar.getInstance(); Calendar calendarTuesday = Calendar.getInstance(); Calendar calendarWednesday = Calendar.getInstance(); Calendar calendarThursday = Calendar.getInstance(); Calendar calendarFriday = Calendar.getInstance(); Calendar calendarSaturday = Calendar.getInstance(); calendarSunday.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY); calendarMonday.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); calendarTuesday.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY); calendarWednesday.set(Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY); calendarThursday.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY); calendarFriday.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY); calendarSaturday.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY); dateSunday = calendarSunday.getTime(); dateMonday = calendarMonday.getTime(); dateTuesday = calendarTuesday.getTime(); dateWednesday = calendarWednesday.getTime(); dateThursday = calendarThursday.getTime(); dateFriday = calendarFriday.getTime(); dateSaturday = calendarSaturday.getTime(); Calendar calendarJanuary = Calendar.getInstance(); Calendar calendarFebruary = Calendar.getInstance(); Calendar calendarMarch = Calendar.getInstance(); Calendar calendarApril = Calendar.getInstance(); Calendar calendarMay = Calendar.getInstance(); Calendar calendarJune = Calendar.getInstance(); Calendar calendarJuly = Calendar.getInstance(); Calendar calendarAugust = Calendar.getInstance(); Calendar calendarSeptember = Calendar.getInstance(); Calendar calendarOctober = Calendar.getInstance(); Calendar calendarNovember = Calendar.getInstance(); Calendar calendarDecember = Calendar.getInstance(); calendarJanuary.set(Calendar.MONTH, Calendar.JANUARY); calendarFebruary.set(Calendar.MONTH, Calendar.FEBRUARY); calendarMarch.set(Calendar.MONTH, Calendar.MARCH); calendarApril.set(Calendar.MONTH, Calendar.APRIL); calendarMay.set(Calendar.MONTH, Calendar.MAY); calendarJune.set(Calendar.MONTH, Calendar.JUNE); calendarJuly.set(Calendar.MONTH, Calendar.JULY); calendarAugust.set(Calendar.MONTH, Calendar.AUGUST); calendarSeptember.set(Calendar.MONTH, Calendar.SEPTEMBER); calendarOctober.set(Calendar.MONTH, Calendar.OCTOBER); calendarNovember.set(Calendar.MONTH, Calendar.NOVEMBER); calendarDecember.set(Calendar.MONTH, Calendar.DECEMBER); dateJanuary = calendarJanuary.getTime(); dateFebruary = calendarFebruary.getTime(); dateMarch = calendarMarch.getTime(); dateApril = calendarApril.getTime(); dateMay = calendarMay.getTime();// w w w. j ava2 s . c o m dateJune = calendarJune.getTime(); dateJuly = calendarJuly.getTime(); dateAugust = calendarAugust.getTime(); dateSeptember = calendarSeptember.getTime(); dateOctober = calendarOctober.getTime(); dateNovember = calendarNovember.getTime(); dateDecember = calendarDecember.getTime(); }
From source file:org.projectforge.framework.configuration.ConfigXmlTest.java
@Test public void testHolidayDefinition() { createTestConfiguration();//from w w w . j a v a 2 s .c o m final ConfigXml config = ConfigXml.getInstance(); assertEquals(5, config.getHolidays().size()); ConfigureHoliday holiday = config.getHolidays().get(0); assertEquals(Calendar.MAY, (int) holiday.getMonth()); holiday = config.getHolidays().get(2); assertEquals(HolidayDefinition.XMAS_EVE, holiday.getId()); holiday = config.getHolidays().get(3); assertEquals(HolidayDefinition.SHROVE_TUESDAY, holiday.getId()); assertEquals(true, holiday.isIgnore()); final Holidays holidays = Holidays.getInstance(); final Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, 2009); cal.set(Calendar.MONTH, Calendar.MAY); cal.set(Calendar.DAY_OF_MONTH, 1); assertEquals("Should be there.", true, holidays.isHoliday(2009, cal.get(Calendar.DAY_OF_YEAR))); cal.set(Calendar.MONTH, Calendar.FEBRUARY); cal.set(Calendar.DAY_OF_MONTH, 23); assertEquals("Should be there.", true, holidays.isHoliday(2009, cal.get(Calendar.DAY_OF_YEAR))); cal.set(Calendar.DAY_OF_MONTH, 24); assertEquals("Should be ignored.", false, holidays.isHoliday(2009, cal.get(Calendar.DAY_OF_YEAR))); }
From source file:org.openhab.persistence.dynamodb.internal.AbstractDynamoDBItemSerializationTest.java
@Test public void testDateTimeTypeWithDateTimeItem() throws IOException { Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); calendar.set(2016, Calendar.MAY, 1, 13, 46, 0); calendar.set(Calendar.MILLISECOND, 50); DynamoDBItem<?> dbitem = testStateGeneric(new DateTimeType(calendar), "2016-05-01T13:46:00.050Z"); testAsHistoricGeneric(dbitem, new DateTimeItem("foo"), new DateTimeType(calendar)); }