List of usage examples for java.util Calendar FEBRUARY
int FEBRUARY
To view the source code for java.util Calendar FEBRUARY.
Click Source Link
From source file:com.mycompany.CRMFly.serviceLayer.ClientsServiceImpl.java
@Transactional public Map<Date, Double> getSumsFotDates(Clients client) { Long id = client.getId();//from w ww. j av a 2s . co 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.set(Calendar.DAY_OF_MONTH, 1); calendar.set(Calendar.HOUR, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); // 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<Contracts> contracts = clientsDAO.getContractsForClient(id); HashMap<Date, Double> sums = new HashMap<Date, Double>(); for (Contracts contract : contracts) { Date date = contract.getBegin_date(); if (date.after(beginningOfQuarter)) thisQuarterSum += contract.getTotalSum(); else if (date.after(QuarterBackOne)) QuarterBackOneSum += contract.getTotalSum(); else if (date.after(QuarterBackTwo)) QuarterBackTwoSum += contract.getTotalSum(); else if (date.after(QuarterBackThree)) QuarterBackThreeSum += contract.getTotalSum(); } 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//from w w w . j av 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:se.skltp.cooperation.web.rest.TestUtil.java
public ConnectionPoint createConnectionPoint(String platform, String environment) { ConnectionPoint connectionPoint = new ConnectionPoint(); connectionPoint.setPlatform(platform); connectionPoint.setEnvironment(environment); connectionPoint.setSnapshotTime(new GregorianCalendar(2014, Calendar.FEBRUARY, 11).getTime()); connectionPointRepository.save(connectionPoint); return connectionPoint; }
From source file:com.mycompany.CRMFly.serviceLayer.ProductsServiceImpl.java
@Transactional public Map<Date, Double> getSumsFotDates(Products product) { Long id = product.getId();//from ww w . ja va 2 s. co 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:org.sakaiproject.coursearchive.logic.CourseArchiveLogicImpl.java
protected String getTerm(int offset) { Calendar calendar = Calendar.getInstance(); int year = calendar.get(Calendar.YEAR); int month = calendar.get(Calendar.MONTH); int term = 1; if (month < Calendar.SEPTEMBER) { year -= 1;//from w w w. j a v a 2s . c om if (month > Calendar.FEBRUARY) { term = 2; } } term += offset; while (term < 1) { year -= 1; term += 2; } while (term > 2) { year += 1; term -= 2; } return String.format("%04d%02d", year, term); }
From source file:com.netflix.simianarmy.basic.BasicCalendar.java
/** * Load holidays./*from w ww .j av a2s.co 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:se.skltp.cooperation.service.DatabaseLoader.java
private void saveDummyConnectionPoint(String platform, String environment) { ConnectionPoint connectionPoint = new ConnectionPoint(); connectionPoint.setPlatform(platform); connectionPoint.setEnvironment(environment); connectionPoint.setSnapshotTime(new GregorianCalendar(2014, Calendar.FEBRUARY, 11).getTime()); connectionPointRepository.save(connectionPoint); loadTAKData(connectionPoint);//from ww w . j a va2 s . c o m }
From source file:com.espertech.esper.regression.pattern.TestCronParameter.java
public void testOperator() throws Exception { // Observer for last Sunday of month, 0 = Sunday int lastDayOfWeek = getLastDayOfWeekInMonth(0, 2007); calendar.set(2007, getCurrentMonth(2007), lastDayOfWeek, 8, 00, 00); printCurrentTime(calendar);/*from w w w . j a va 2 s. c o m*/ baseTime = calendar.getTimeInMillis(); testData = getEventSet(baseTime, 1000 * 60 * 10); expressionText = "timer:at(*, *, *, *, 0 last, *)"; testCase = new EventExpressionCase(expressionText); testCase.add("A1"); runTestEvent(); // Observer for last day of current month calendar.set(2007, getCurrentMonth(2007), getLastDayOfMonth(2007), 8, 00, 00); printCurrentTime(calendar); baseTime = calendar.getTimeInMillis(); testData = getEventSet(baseTime, 1000 * 60 * 10); expressionText = "timer:at(*, *, last, *, *, *)"; testCase = new EventExpressionCase(expressionText); testCase.add("A1"); runTestEvent(); // Observer for last day of Auguts 2007 // For Java: January=0, February=1, March=2, April=3, May=4, June=5, // July=6, August=7, September=8, November=9, October=10, December=11 // For Esper: January=1, February=2, March=3, April=4, May=5, June=6, // July=7, August=8, September=9, November=10, October=11, December=12 calendar.set(2007, Calendar.AUGUST, 31, 8, 00, 00); printCurrentTime(calendar); baseTime = calendar.getTimeInMillis(); testData = getEventSet(baseTime, 1000 * 60 * 10); expressionText = "timer:at(*, *, last, 8, *, *)"; testCase = new EventExpressionCase(expressionText); testCase.add("A1"); runTestEvent(); // Observer for last day of February 2007 calendar.set(2007, Calendar.FEBRUARY, 28, 8, 00, 00); printCurrentTime(calendar); baseTime = calendar.getTimeInMillis(); testData = getEventSet(baseTime, 1000 * 60 * 10); expressionText = "timer:at(*, *, last, 2, *, *)"; testCase = new EventExpressionCase(expressionText); testCase.add("A1"); runTestEvent(); // Observer for last day of week (Saturday) Calendar calendar = Calendar.getInstance(); Date date = new Date(); calendar.setTime(date); calendar.set(Calendar.MILLISECOND, 0); calendar.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY); printCurrentTime(calendar); baseTime = calendar.getTimeInMillis(); testData = getEventSet(baseTime, 1000 * 60 * 10); expressionText = "timer:at(*, *, *, *, last, *)"; testCase = new EventExpressionCase(expressionText); testCase.add("A1"); runTestEvent(); // Observer for last Friday of June calendar.set(2007, Calendar.JUNE, 29, 8, 00, 00); printCurrentTime(calendar); baseTime = calendar.getTimeInMillis(); testData = getEventSet(baseTime, 1000 * 60 * 10); expressionText = "timer:at(*, *, *, 6, 5 last, *)"; testCase = new EventExpressionCase(expressionText); testCase.add("A1"); runTestEvent(); // Observer for last weekday of the current month calendar.set(2007, getCurrentMonth(2007), getLastWeekDayOfMonth(null, 2007), 8, 00, 00); printCurrentTime(calendar); baseTime = calendar.getTimeInMillis(); testData = getEventSet(baseTime, 1000 * 60 * 10); expressionText = "timer:at(*, *, lastweekday, *, *, *)"; testCase = new EventExpressionCase(expressionText); testCase.add("A1"); runTestEvent(); // Observer for last weekday of September 2007, it's Friday September 28th calendar.set(2007, Calendar.SEPTEMBER, 28, 10, 00, 00); printCurrentTime(calendar); baseTime = calendar.getTimeInMillis(); testData = getEventSet(baseTime, 1000 * 60 * 10); expressionText = "timer:at(*, *, lastweekday, 9, *, *)"; testCase = new EventExpressionCase(expressionText); testCase.add("A1"); runTestEvent(); // Observer for last weekday of February, it's Wednesday February 28th calendar.set(2007, Calendar.FEBRUARY, 28, 8, 00, 00); printCurrentTime(calendar); baseTime = calendar.getTimeInMillis(); testData = getEventSet(baseTime, 1000 * 60 * 10); expressionText = "timer:at(*, *, lastweekday, 2, *, *)"; testCase = new EventExpressionCase(expressionText); testCase.add("A1"); runTestEvent(); // Observer for nearest weekday for current month on the 10th calendar.set(2007, getCurrentMonth(2007), getLastWeekDayOfMonth(10, 2007), 8, 00, 00); printCurrentTime(calendar); baseTime = calendar.getTimeInMillis(); testData = getEventSet(baseTime, 1000 * 60 * 10); expressionText = "timer:at(*, *, 10 weekday, *, *, *)"; testCase = new EventExpressionCase(expressionText); testCase.add("A1"); runTestEvent(); // Observer for nearest weekday of September 1st (Saturday), it's Monday September 3rd (no "jump" over month) calendar.set(2007, Calendar.SEPTEMBER, 3, 8, 00, 00); printCurrentTime(calendar); baseTime = calendar.getTimeInMillis(); testData = getEventSet(baseTime, 1000 * 60 * 10); expressionText = "timer:at(*, *, 1 weekday, 9, *, *)"; testCase = new EventExpressionCase(expressionText); testCase.add("A1"); runTestEvent(); // Observer for nearest weekday of September 30th (Sunday), it's Friday September 28th (no "jump" over month) calendar.set(2007, Calendar.SEPTEMBER, 28, 8, 00, 00); printCurrentTime(calendar); baseTime = calendar.getTimeInMillis(); testData = getEventSet(baseTime, 1000 * 60 * 10); expressionText = "timer:at(*, *, 30 weekday, 9, *, *)"; testCase = new EventExpressionCase(expressionText); testCase.add("A1"); runTestEvent(); // Observer for last Friday of current month, // 0=Sunday, 1=Monday, 2=Tuesday, 3=Wednesday, 4= Thursday, 5=Friday, 6=Saturday calendar.set(2007, getCurrentMonth(2007), getLastDayOfWeekInMonth(5, 2007), 8, 00, 00); printCurrentTime(calendar); baseTime = calendar.getTimeInMillis(); testData = getEventSet(baseTime, 1000 * 60 * 10); expressionText = "timer:at(*, *, *, *, 5 last, *)"; testCase = new EventExpressionCase(expressionText); testCase.add("A1"); runTestEvent(); }
From source file:org.openmrs.module.radiology.test.RadiologyTestData.java
/** * Convenience method constructing a mock RadiologyOrder for the tests *//*from www .ja v a 2 s . co m*/ public static RadiologyOrder getMockRadiologyOrder1() { RadiologyOrder mockRadiologyOrder = new RadiologyOrder(); mockRadiologyOrder.setOrderId(1); mockRadiologyOrder.setOrderType(getMockRadiologyOrderType()); mockRadiologyOrder.setPatient(getMockPatient1()); Calendar calendar = Calendar.getInstance(); calendar.set(2015, Calendar.FEBRUARY, 4, 14, 35, 0); mockRadiologyOrder.setScheduledDate(calendar.getTime()); mockRadiologyOrder.setUrgency(Order.Urgency.ON_SCHEDULED_DATE); mockRadiologyOrder.setInstructions("CT ABDOMEN PANCREAS WITH IV CONTRAST"); mockRadiologyOrder.setVoided(false); mockRadiologyOrder.setStudy(getMockStudy1PostSave()); return mockRadiologyOrder; }
From source file:ca.uhn.hl7v2.model.primitive.CommonTSTest.java
/** * See bug 3545328/*from w w w . ja va 2s . co m*/ * * This bug has not yet been evaluated, so the test will fail. */ @Test public void testOffsetProblem() throws HL7Exception { GregorianCalendar hapiTestCalendar = (GregorianCalendar) GregorianCalendar .getInstance(TimeZone.getTimeZone("CET")); hapiTestCalendar.set(2012, Calendar.FEBRUARY, 1); hapiTestCalendar = (GregorianCalendar) DateUtils.truncate(hapiTestCalendar, Calendar.DATE); assertEquals("20120201000000+0100", CommonTS.toHl7TSFormat(hapiTestCalendar)); hapiTestCalendar.set(2012, Calendar.AUGUST, 1); assertEquals("20120801000000+0200", CommonTS.toHl7TSFormat(hapiTestCalendar)); }