List of usage examples for java.util Calendar JANUARY
int JANUARY
To view the source code for java.util Calendar JANUARY.
Click Source Link
From source file:cz.muni.pa165.carparkapp.Service.LoanServiceImplTest.java
@Before public void setUp() { Calendar cal1 = Calendar.getInstance(); cal1.set(1980, Calendar.JANUARY, 1); Date date1 = cal1.getTime();//from w w w . j a v a2s .c o m branch1 = new Branch(); branch1.setId(1); branch1.setAddress("Brno"); branch1.setCompanyNumber("123456"); branch1.setName("Pobocka 45"); branchDto1 = new BranchDTO(); branchDto1.setId(1); branchDto1.setAddress("Brno"); branchDto1.setCompanyNumber("123456"); branchDto1.setName("Pobocka 45"); branch2 = new Branch(); branch2.setId(2); branch2.setAddress("Brno"); branch2.setCompanyNumber("123456"); branch2.setName("Pobocka 45"); branchDto2 = new BranchDTO(); branchDto2.setId(2); branchDto2.setAddress("Brno"); branchDto2.setCompanyNumber("123456"); branchDto2.setName("Pobocka 45"); car1 = new Car(); car1.setRegistrationNumber("TT-588-BA"); car1.setType("Skoda"); car1.setModel("Octavia"); car1.setColor("Black"); car1.setFuel("Diesel"); car1.setVin("1415415"); car1.setId(1); car2 = new Car(); car2.setRegistrationNumber("BA-211-CJ"); car2.setType("Opel"); car2.setModel("Meriva"); car2.setColor("White"); car2.setFuel("Oil"); car2.setVin("57772332"); car2.setId(2); carDto1 = new CarDTO(1, "TT-588-BA", "Skoda", "Octavia", "1415415", "Diesel", "Black"); carDto2 = new CarDTO(2, "BA-211-CJ", "Opel", "Meriva", "57772332", "Oil", "White"); employeeDto1 = new EmployeeDTO(); employeeDto1.setId(1); employeeDto1.setFirstName("Jano"); employeeDto1.setLastName("Novak"); employeeDto1.setAddress("Botanicka 68a, 60200 Brno"); employeeDto1.setBirthNumber("821104/5478"); employeeDto1.setTelNumber("765864356"); employeeDto2 = new EmployeeDTO(); employeeDto2.setId(2); employeeDto2.setFirstName("Eva"); employeeDto2.setLastName("Novotna"); employeeDto2.setAddress("Nadrazni 18, 60300 Brno"); employeeDto2.setBirthNumber("821104/7548"); employeeDto2.setTelNumber("578687899"); employee1 = new Employee(); employee1.setFirstName("Jano"); employee1.setLastName("Novak"); employee1.setAddress("Botanicka 68a, 60200 Brno"); employee1.setBirthNumber("821104/5478"); employee1.setTelNumber("765864356"); employee2 = new Employee(); employee2.setFirstName("Eva"); employee2.setLastName("Novotna"); employee2.setAddress("Nadrazni 18, 60300 Brno"); employee2.setBirthNumber("821104/7548"); employee2.setTelNumber("578687899"); loan1 = new Loan(); loan1.setId(1); loan1.setBranch(branch1); loan1.setCar(car1); loan1.setEmployee(employee1); loan1.setStartDate(date1); loan1.setEndDate(date1); loan2 = new Loan(); loan2.setId(2); loan2.setBranch(branch2); loan2.setCar(car2); loan2.setEmployee(employee2); loan2.setStartDate(date1); loan2.setEndDate(date1); loanDto1 = new LoanDTO(); loanDto1.setId(1); loanDto1.setBranch(branchDto1); loanDto1.setCar(carDto1); loanDto1.setEmployee(employeeDto1); loanDto1.setStartDate(date1); loanDto1.setEndDate(date1); loanDto2 = new LoanDTO(); loanDto2.setId(2); loanDto2.setBranch(branchDto2); loanDto2.setCar(carDto2); loanDto2.setEmployee(employeeDto2); loanDto2.setStartDate(date1); loanDto2.setEndDate(date1); carService.addCar(carDto1); employeeService.addEmployee(employeeDto1); branchService.addBranch(branchDto1); carService.addCar(carDto2); employeeService.addEmployee(employeeDto2); branchService.addBranch(branchDto2); }
From source file:org.osframework.contract.date.fincal.holiday.producer.SingleYearProducer.java
private void addWeekends(FinancialCalendar calendar, List<Holiday> holidays) { c.clear();/* w ww .ja v a 2s . c o m*/ c.set(year, Calendar.JANUARY, 1); while (c.get(Calendar.YEAR) == year) { if (Calendar.SATURDAY == c.get(Calendar.DAY_OF_WEEK) || Calendar.SUNDAY == c.get(Calendar.DAY_OF_WEEK)) { holidays.add(new Holiday(calendar, c.getTime(), WEEKEND_HOLIDAY_DEFINITION)); } c.add(Calendar.DAY_OF_MONTH, 1); } }
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 a v a2 s . c o m * * @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:moviemanager.backend.PersonManagerTest.java
/** * Unit test for searching for person by it's ID. *//*w w w. ja v a 2s . c om*/ @Test public void testFindPersonWithID() { log.info("Testing searching for person by ID..."); try { Calendar calendar = new GregorianCalendar(1933, Calendar.JANUARY, 9); Person person = new Person("Wilbur Smith (Find)", calendar); personManager.createPerson(person); Person addedPerson = personManager.getPerson(person.getId()); assertNotSame("Created person is not the same as found person.", person, addedPerson); personManager.deletePerson(person.getId()); assertNull("Person found after removing it.", personManager.getPerson(person.getId())); } catch (NullPointerException ex) { System.out.println("Attempt to create new person resulted in " + ex); } catch (ServiceFailureException ex) { Logger.getLogger(PersonManagerTest.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:ch.ralscha.extdirectspring.controller.RouterControllerFormLoadTest.java
@Test public void testFormLoad() { Map<String, Object> data = new HashMap<String, Object>(); data.put("d", 3.141); ExtDirectFormLoadResult wrapper = (ExtDirectFormLoadResult) ControllerUtil.sendAndReceive(mockMvc, "remoteProviderFormLoad", "method1", ExtDirectFormLoadResult.class, data); assertThat(wrapper.isSuccess()).isTrue(); assertThat(wrapper.getData()).isNotNull(); FormInfo info = ControllerUtil.convertValue(wrapper.getData(), FormInfo.class); assertThat(info.getBack()).isEqualTo(3.141); assertThat(info.isAdmin()).isEqualTo(true); assertThat(info.getAge()).isEqualTo(31); assertThat(info.getName()).isEqualTo("Bob"); assertThat(info.getSalary()).isEqualTo(new BigDecimal("10000.55")); assertThat(info.getBirthday()).isEqualTo(new GregorianCalendar(1980, Calendar.JANUARY, 15).getTime()); }
From source file:org.osframework.contract.date.fincal.holiday.producer.SingleFinancialCalendarProducer.java
private void addWeekends(int year, List<Holiday> holidays) { c.clear();//from w w w . j ava2 s . co m c.set(year, Calendar.JANUARY, 1); while (c.get(Calendar.YEAR) == year) { if (Calendar.SATURDAY == c.get(Calendar.DAY_OF_WEEK) || Calendar.SUNDAY == c.get(Calendar.DAY_OF_WEEK)) { holidays.add(new Holiday(calendar, c.getTime(), WEEKEND_HOLIDAY_DEFINITION)); } c.add(Calendar.DAY_OF_MONTH, 1); } }
From source file:org.lieuofs.geo.territoire.biz.dao.EtatTerritoireFichierXmlDaoTest.java
@Test public void lireSuisse() { EtatTerritoirePersistant suisse = dao.lire(8100); assertEquals("N OFS Suisse", 8100, suisse.getNumeroOFS()); InfosONUetISO3166 infos = suisse.getInfosISO(); assertNotNull("Infos Onu Iso non nulles", infos); assertEquals("Info Onu numrique", 756, infos.getCodeNumeriqueONU()); assertEquals("Info ISO alpha 2", "CH", infos.getCodeIsoAlpha2()); assertEquals("Info ISO alpha 3", "CHE", infos.getCodeIsoAlpha3()); assertEquals("Forme courte allemande", "Schweiz", suisse.getFormeCourte("de")); assertEquals("Forme courte franaise", "Suisse", suisse.getFormeCourte("fr")); assertEquals("Forme courte italienne", "Svizzera", suisse.getFormeCourte("it")); assertEquals("Forme courte anglaise", "Switzerland", suisse.getFormeCourte("en")); assertEquals("Dsignation allemande", "Schweizerische Eidgenossenschaft", suisse.getDesignationOfficielle("de")); assertEquals("Dsignation franaise", "Confdration suisse", suisse.getDesignationOfficielle("fr")); assertEquals("Dsignation italienne", "Confederazione svizzera", suisse.getDesignationOfficielle("it")); assertEquals("Continent", 1, suisse.getNumContinent()); assertEquals("Rgion", 3, suisse.getNumRegion()); assertTrue("Est un tat", suisse.isEtat()); assertEquals("La Suisse est un tat : pas de rattachement", 0, suisse.getNumEtatRattachement()); assertTrue("Est membre de l'ONU", suisse.isMembreONU()); Calendar cal = Calendar.getInstance(); cal.setTime(suisse.getDateEntreeONU()); assertEquals("Jour entre ONU", 10, cal.get(Calendar.DATE)); assertEquals("mois entre ONU", Calendar.SEPTEMBER, cal.get(Calendar.MONTH)); assertEquals("anne entre ONU", 2002, cal.get(Calendar.YEAR)); assertFalse("Non reconnu par la Suisse", suisse.isReconnuSuisse()); assertNull("Date reconnaissance Suisse", suisse.getDateReconnaissance()); assertNull("Remarque en allemand", suisse.getRemarque("de")); assertNull("Remarque en franais", suisse.getRemarque("fr")); assertNull("Remarque en italien", suisse.getRemarque("it")); assertTrue("valide", suisse.isValide()); cal.setTime(suisse.getDateDernierChangement()); assertEquals("Jour dernier changement", 1, cal.get(Calendar.DATE)); assertEquals("mois dernier changement", Calendar.JANUARY, cal.get(Calendar.MONTH)); assertEquals("anne dernier changement", 2008, cal.get(Calendar.YEAR)); }
From source file:com.mycompany.CRMFly.serviceLayer.ProductsServiceImpl.java
@Transactional public Map<Date, Double> getSumsFotDates(Products product) { Long id = product.getId();//ww w . jav a 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:com.gargoylesoftware.htmlunit.httpclient.HtmlUnitExpiresHandler.java
@Override public void parse(final SetCookie cookie, String value) throws MalformedCookieException { if (value.startsWith("\"") && value.endsWith("\"")) { value = value.substring(1, value.length() - 1); }/*from w w w .j a v a2s .c om*/ value = value.replaceAll("[ ,:-]+", " "); Date startDate = null; String[] datePatterns = DEFAULT_DATE_PATTERNS; if (null != browserVersion_) { if (browserVersion_.hasFeature(HTTP_COOKIE_START_DATE_1970)) { startDate = HtmlUnitBrowserCompatCookieSpec.DATE_1_1_1970; } if (browserVersion_.hasFeature(HTTP_COOKIE_EXTENDED_DATE_PATTERNS_1)) { datePatterns = EXTENDED_DATE_PATTERNS_1; } if (browserVersion_.hasFeature(HTTP_COOKIE_EXTENDED_DATE_PATTERNS_2)) { final Calendar calendar = Calendar.getInstance(Locale.ROOT); calendar.setTimeZone(DateUtils.GMT); calendar.set(1969, Calendar.JANUARY, 1, 0, 0, 0); calendar.set(Calendar.MILLISECOND, 0); startDate = calendar.getTime(); datePatterns = EXTENDED_DATE_PATTERNS_2; } } final Date expiry = DateUtils.parseDate(value, datePatterns, startDate); cookie.setExpiryDate(expiry); }
From source file:ch.puzzle.itc.mobiliar.business.generator.control.extracted.ResourceDependencyResolverServiceTest.java
@Test public void testFindNearestRelease() { // given/*from w w w . j a v a2 s.c o m*/ Calendar cal = new GregorianCalendar(); cal.set(2001, Calendar.JANUARY, 1); ReleaseEntity release1 = createRelease(1, new Date(cal.getTimeInMillis())); cal.set(2013, Calendar.JANUARY, 1); ReleaseEntity release2 = createRelease(2, new Date(cal.getTimeInMillis())); cal.set(2013, Calendar.JANUARY, 23); ReleaseEntity release3 = createRelease(3, new Date(cal.getTimeInMillis())); cal.set(2013, Calendar.AUGUST, 8); ReleaseEntity release4 = createRelease(4, new Date(cal.getTimeInMillis())); cal.set(2013, Calendar.DECEMBER, 31); ReleaseEntity release5 = createRelease(5, new Date(cal.getTimeInMillis())); cal.set(2014, Calendar.NOVEMBER, 10); ReleaseEntity release6 = createRelease(6, new Date(cal.getTimeInMillis())); SortedSet<ReleaseEntity> releases = new TreeSet<ReleaseEntity>(); // when only past release exists releases.add(release1); cal.set(2013, Calendar.JANUARY, 10); ReleaseEntity nearestRelease = service.findMostRelevantRelease(releases, new Date(cal.getTimeInMillis())); // then assertEquals(release1.getId(), nearestRelease.getId()); // when there are multiple past releases releases.add(release2); releases.add(release3); cal.set(2013, Calendar.FEBRUARY, 10); nearestRelease = service.findMostRelevantRelease(releases, new Date(cal.getTimeInMillis())); // then assertEquals(release3.getId(), nearestRelease.getId()); // when there is one future release releases.add(release4); cal.set(2013, Calendar.FEBRUARY, 10); nearestRelease = service.findMostRelevantRelease(releases, new Date(cal.getTimeInMillis())); // then assertEquals(release4.getId(), nearestRelease.getId()); // when there are multiple future releases cal.set(2013, Calendar.AUGUST, 9); releases.add(release5); releases.add(release6); nearestRelease = service.findMostRelevantRelease(releases, new Date(cal.getTimeInMillis())); // then Assert.assertEquals(release5.getId(), nearestRelease.getId()); }