List of usage examples for java.util Calendar APRIL
int APRIL
To view the source code for java.util Calendar APRIL.
Click Source Link
From source file:com.lastsoft.plog.adapter.GameAdapter.java
public void playPopup(View v, final int position) { try {//from w w w.java2 s . c o m InputMethodManager inputManager = (InputMethodManager) mActivity .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(mActivity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } catch (Exception ignored) { } PopupMenu popup = new PopupMenu(mActivity, v); MenuInflater inflater = popup.getMenuInflater(); if (games.get(position).expansionFlag == true) { inflater.inflate(R.menu.game_expansion_overflow, popup.getMenu()); } else { inflater.inflate(R.menu.game_overflow, popup.getMenu()); } if (games.get(position).gameBGGID == null || games.get(position).gameBGGID.equals("")) { popup.getMenu().removeItem(R.id.update_bgg); popup.getMenu().removeItem(R.id.open_bgg); popup.getMenu().removeItem(R.id.add_bgg); } if (games.get(position).gameBoxImage == null || games.get(position).gameBoxImage.equals("")) { popup.getMenu().removeItem(R.id.view_box_photo); } if (games.get(position).taggedToPlay <= 0) { popup.getMenu().removeItem(R.id.remove_bucket_list); } else { popup.getMenu().removeItem(R.id.add_bucket_list); } SharedPreferences app_preferences; app_preferences = PreferenceManager.getDefaultSharedPreferences(mActivity); long currentDefaultPlayer = app_preferences.getLong("defaultPlayer", -1); if (games.get(position).collectionFlag || currentDefaultPlayer == -1) { popup.getMenu().removeItem(R.id.add_bgg); } //check if this game has been played //if so, can't delete if (GamesPerPlay.hasGameBeenPlayed(games.get(position))) { popup.getMenu().removeItem(R.id.delete_game); } popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.delete_game: ((MainActivity) mActivity).deleteGame(games.get(position).getId()); return true; case R.id.add_tenbyten: ((MainActivity) mActivity).addToTenXTen(games.get(position).getId()); return true; case R.id.view_plays: if (games.get(position).expansionFlag == true) { ((MainActivity) mActivity).openPlays(games.get(position).gameName, false, 9, fragmentName, currentYear); } else { ((MainActivity) mActivity).openPlays(games.get(position).gameName, false, 0, fragmentName, currentYear); } return true; case R.id.open_bgg: Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://bgg.cc/boardgame/" + games.get(position).gameBGGID)); mActivity.startActivity(browserIntent); return true; case R.id.update_bgg: mPosition = position; if (games.get(position).expansionFlag == true) { ((MainActivity) mActivity).searchGameViaBGG(games.get(position).gameName, false, true, -1); } else { ((MainActivity) mActivity).searchGameViaBGG(games.get(position).gameName, false, false, -1); } return true; case R.id.add_bgg: mPosition = position; ((MainActivity) mActivity).updateGameViaBGG(games.get(position).gameName, games.get(position).gameBGGID, "", true, false); return true; case R.id.add_box_photo: ((GamesFragment) mFragment).captureBox(games.get(position)); return true; case R.id.view_box_photo: String[] photoParts = games.get(position).gameBoxImage.split("/"); File newFile = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + "/Plog/", photoParts[photoParts.length - 1]); Uri contentUri = FileProvider.getUriForFile(mActivity.getApplicationContext(), "com.lastsoft.plog.fileprovider", newFile); Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setDataAndType(contentUri, "image/*"); intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); mActivity.startActivity(intent); return true; case R.id.add_bucket_list: String[] ids = TimeZone.getAvailableIDs(-5 * 60 * 60 * 1000); // if no ids were returned, something is wrong. get out. //if (ids.length == 0) // System.exit(0); // begin output //System.out.println("Current Time"); // create a Eastern Standard Time time zone SimpleTimeZone pdt = new SimpleTimeZone(-5 * 60 * 60 * 1000, ids[0]); // set up rules for daylight savings time pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000); pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000); // create a GregorianCalendar with the Pacific Daylight time zone // and the current date and time Calendar calendar = new GregorianCalendar(pdt); Date trialTime = new Date(); calendar.setTime(trialTime); int i = (int) (calendar.getTime().getTime() / 1000); games.get(position).taggedToPlay = i; games.get(position).save(); Snackbar.make(((GamesFragment) mFragment).mCoordinatorLayout, games.get(position).gameName + mActivity.getString(R.string.added_to_bl), Snackbar.LENGTH_LONG) .setAction(mActivity.getString(R.string.undo), new View.OnClickListener() { @Override public void onClick(View view) { games.get(position).taggedToPlay = 0; games.get(position).save(); if (playListType == 2) { ((MainActivity) mActivity).onFragmentInteraction("refresh_games"); } } }).show(); // Do not forget to show! return true; case R.id.remove_bucket_list: final int taggedToPlay = games.get(position).taggedToPlay; final Game gameToUndo = games.get(position); games.get(position).taggedToPlay = 0; games.get(position).save(); Snackbar.make(((GamesFragment) mFragment).mCoordinatorLayout, games.get(position).gameName + mActivity.getString(R.string.removed_from_bl), Snackbar.LENGTH_LONG) .setAction(mActivity.getString(R.string.undo), new View.OnClickListener() { @Override public void onClick(View view) { gameToUndo.taggedToPlay = taggedToPlay; gameToUndo.save(); if (playListType == 2) { ((MainActivity) mActivity).onFragmentInteraction("refresh_games"); } } }).show(); // Do not forget to show! if (playListType == 2) { ((MainActivity) mActivity).onFragmentInteraction("refresh_games"); } return true; default: return false; } } } ); popup.show(); }
From source file:edu.ucsb.nceas.MCTestCase.java
/** * Create a unique docid for testing insert and update. Does not * include the 'revision' part of the id. * /*from w w w . j a va 2 s .c o m*/ * @return a String docid based on the current date and time */ protected String generateDocumentId() { try { Thread.sleep(1010); } catch (InterruptedException ie) { debug("Could not sleep: " + ie.getMessage()); } StringBuffer docid = new StringBuffer(prefix); docid.append("."); // Create a calendar to get the date formatted properly String[] ids = TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000); SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]); pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000); pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000); Calendar calendar = new GregorianCalendar(pdt); Date trialTime = new Date(); calendar.setTime(trialTime); docid.append(calendar.get(Calendar.YEAR)); docid.append(calendar.get(Calendar.DAY_OF_YEAR)); docid.append(calendar.get(Calendar.HOUR_OF_DAY)); docid.append(calendar.get(Calendar.MINUTE)); docid.append(calendar.get(Calendar.SECOND)); return docid.toString(); }
From source file:com.gemstone.gemfire.rest.internal.web.controllers.RestAPIsAndInterOpsDUnitTest.java
public static void verifyUpdatesInClientCache() { ClientCache cache = GemFireCacheImpl.getInstance(); assertNotNull(cache);//from w w w.j av a 2s . c o m Region<String, Object> region = cache.getRegion(PEOPLE_REGION_NAME); { Person expectedPerson = new Person(3L, "Nishka3", "Nilkanth3", "Patel3", DateTimeUtils.createDate(2009, Calendar.JULY, 31), Gender.FEMALE); Object value = region.get("3"); if (value instanceof PdxInstance) { PdxInstance pi3 = (PdxInstance) value; Person actualPerson = (Person) pi3.getObject(); assertEquals(actualPerson.getId(), expectedPerson.getId()); assertEquals(actualPerson.getFirstName(), expectedPerson.getFirstName()); assertEquals(actualPerson.getMiddleName(), expectedPerson.getMiddleName()); assertEquals(actualPerson.getLastName(), expectedPerson.getLastName()); assertEquals(actualPerson.getBirthDate(), expectedPerson.getBirthDate()); assertEquals(actualPerson.getGender(), expectedPerson.getGender()); } else if (value instanceof Person) { fail("VerifyUpdatesInClientCache, Get on key 3, Expected to get value of type PdxInstance "); } } //TODO: uncomment it once following issue encountered in put?op=CAS is fixed or document the issue // CAS functionality is not working in following test case // step-1: Java client, Region.put("K", A); //Step-2: Rest CAS request for key "K" with data "@old" = A. CAS is failing as existing PdxInstance in cache and // PdxInstance generated from JSON (CAS request) does not match as their value's type are getting changed /* //verify update on key "1" { Object obj = region.get("1"); if (obj instanceof PdxInstance) { PdxInstance pi = (PdxInstance)obj; Person p1 = (Person)pi.getObject(); System.out.println("Nilkanth1 : verifyUpdatesInClientCache() : GET ON KEY=1" + p1.toString()); }else { System.out.println("Nilkanth1 : verifyUpdatesInClientCache() GET ON KEY=1 returned OBJECT: " + obj.toString()); } } */ //verify update on key "2" { Person expectedPerson = new Person(501L, "Barack", "Hussein", "Obama", DateTimeUtils.createDate(1961, Calendar.APRIL, 8), Gender.MALE); Object value = region.get("2"); if (value instanceof PdxInstance) { PdxInstance pi3 = (PdxInstance) value; Person actualPerson = (Person) pi3.getObject(); assertEquals(actualPerson.getId(), expectedPerson.getId()); assertEquals(actualPerson.getFirstName(), expectedPerson.getFirstName()); assertEquals(actualPerson.getMiddleName(), expectedPerson.getMiddleName()); assertEquals(actualPerson.getLastName(), expectedPerson.getLastName()); assertEquals(actualPerson.getBirthDate(), expectedPerson.getBirthDate()); assertEquals(actualPerson.getGender(), expectedPerson.getGender()); } else { fail("VerifyUpdatesInClientCache, Get on key 2, Expected to get value of type PdxInstance "); } } //verify Deleted key "13" { Object obj = region.get("13"); assertEquals(obj, null); obj = region.get("14"); assertEquals(obj, null); obj = region.get("15"); assertEquals(obj, null); obj = region.get("16"); assertEquals(obj, null); } }
From source file:gbc.jtimecalc.AbstractTimeDifferenceCalculatorTest.java
private void prepareStartEndAndExpectedValueForBusinessDays(String messageKey, int numOfDays) { Calendar end = prepareCalendar(2012, Calendar.APRIL, 30, 0, 0, 0, 0); // 30.04.2012 00:00:00.0 - Monday setEndTime(endTime = end.getTimeInMillis()); setStartTime(substractFromDate(endTime, numOfDays, 0, 0, 0, 0)); expectedValue = messages.get(messageKey); }
From source file:org.apache.geode.rest.internal.web.controllers.RestAPIsAndInterOpsDUnitTest.java
public void verifyUpdatesInClientCache() { ClientCache cache = GemFireCacheImpl.getInstance(); assertNotNull(cache);// w w w .ja v a 2 s . c om Region<String, Object> region = cache.getRegion(PEOPLE_REGION_NAME); { Person expectedPerson = new Person(3L, "Nishka3", "Nilkanth3", "Patel3", DateTimeUtils.createDate(2009, Calendar.JULY, 31), Gender.FEMALE); Object value = region.get("3"); if (value instanceof PdxInstance) { PdxInstance pi3 = (PdxInstance) value; Person actualPerson = (Person) pi3.getObject(); assertEquals(actualPerson.getId(), expectedPerson.getId()); assertEquals(actualPerson.getFirstName(), expectedPerson.getFirstName()); assertEquals(actualPerson.getMiddleName(), expectedPerson.getMiddleName()); assertEquals(actualPerson.getLastName(), expectedPerson.getLastName()); assertEquals(actualPerson.getBirthDate(), expectedPerson.getBirthDate()); assertEquals(actualPerson.getGender(), expectedPerson.getGender()); } else if (value instanceof Person) { fail("VerifyUpdatesInClientCache, Get on key 3, Expected to get value of type PdxInstance "); } } // TODO: uncomment it once following issue encountered in put?op=CAS is fixed or document the // issue // CAS functionality is not working in following test case // step-1: Java client, Region.put("K", A); // Step-2: Rest CAS request for key "K" with data "@old" = A. CAS is failing as existing // PdxInstance in cache and // PdxInstance generated from JSON (CAS request) does not match as their value's type are // getting changed /* * //verify update on key "1" { Object obj = region.get("1"); if (obj instanceof PdxInstance) { * PdxInstance pi = (PdxInstance)obj; Person p1 = (Person)pi.getObject(); * System.out.println("Nilkanth1 : verifyUpdatesInClientCache() : GET ON KEY=1" + * p1.toString()); }else { * System.out.println("Nilkanth1 : verifyUpdatesInClientCache() GET ON KEY=1 returned OBJECT: " * + obj.toString()); } } */ // verify update on key "2" { Person expectedPerson = new Person(501L, "Barack", "Hussein", "Obama", DateTimeUtils.createDate(1961, Calendar.APRIL, 8), Gender.MALE); Object value = region.get("2"); if (value instanceof PdxInstance) { PdxInstance pi3 = (PdxInstance) value; Person actualPerson = (Person) pi3.getObject(); assertEquals(actualPerson.getId(), expectedPerson.getId()); assertEquals(actualPerson.getFirstName(), expectedPerson.getFirstName()); assertEquals(actualPerson.getMiddleName(), expectedPerson.getMiddleName()); assertEquals(actualPerson.getLastName(), expectedPerson.getLastName()); assertEquals(actualPerson.getBirthDate(), expectedPerson.getBirthDate()); assertEquals(actualPerson.getGender(), expectedPerson.getGender()); } else { fail("VerifyUpdatesInClientCache, Get on key 2, Expected to get value of type PdxInstance "); } } // verify Deleted key "13" { Object obj = region.get("13"); assertEquals(obj, null); obj = region.get("14"); assertEquals(obj, null); obj = region.get("15"); assertEquals(obj, null); obj = region.get("16"); assertEquals(obj, null); } }
From source file:org.openmrs.module.radiology.DicomUtilsComponentTest.java
/** * Convenience method to create a mock radiology order *//*from w ww. j a v a2 s . co m*/ RadiologyOrder getMockRadiologyOrder() throws Exception { Patient mockPatient = new Patient(); mockPatient.setPatientId(1); PatientIdentifierType patientIdentifierType = new PatientIdentifierType(); patientIdentifierType.setPatientIdentifierTypeId(1); patientIdentifierType.setName("Test Identifier Type"); patientIdentifierType.setDescription("Test description"); PatientIdentifier patientIdentifier = new PatientIdentifier(); patientIdentifier.setIdentifierType(patientIdentifierType); patientIdentifier.setIdentifier("100"); patientIdentifier.setPreferred(true); Set<PatientIdentifier> patientIdentifiers = new HashSet<PatientIdentifier>(); patientIdentifiers.add(patientIdentifier); mockPatient.addIdentifiers(patientIdentifiers); mockPatient.setGender("M"); Set<PersonName> personNames = new HashSet<PersonName>(); PersonName personName = new PersonName(); personName.setFamilyName("Doe"); personName.setGivenName("John"); personName.setMiddleName("Francis"); personNames.add(personName); mockPatient.setNames(personNames); Calendar calendar = Calendar.getInstance(); calendar.set(1950, Calendar.APRIL, 1, 0, 0, 0); mockPatient.setBirthdate(calendar.getTime()); RadiologyOrder mockRadiologyOrder = new RadiologyOrder(); mockRadiologyOrder.setOrderId(20); Field orderNumber = Order.class.getDeclaredField("orderNumber"); orderNumber.setAccessible(true); orderNumber.set(mockRadiologyOrder, "ORD-" + mockRadiologyOrder.getOrderId()); mockRadiologyOrder.setPatient(mockPatient); 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"); return mockRadiologyOrder; }
From source file:at.ac.tuwien.ifs.tita.dao.test.util.HibernateBaseTest.java
private void createEfforts() { // user3 - issuetrackertask 1, 2, 3 titatask 1, 2, 3 effort1 = new Effort(null, task1, new GregorianCalendar(2010, Calendar.APRIL, 17).getTime(), 100000L, 200000L, 100000L, "effort 1", false, "540", user3); effort2 = new Effort(null, task2, new GregorianCalendar(2010, Calendar.APRIL, 17).getTime(), 100000L, 200000L, 100000L, "effort 1", false, "540", user3); effort3 = new Effort(null, task3, new GregorianCalendar(2010, Calendar.APRIL, 17).getTime(), 100000L, 200000L, 100000L, "effort 1", false, "540", user3); effort4 = new Effort(titaTask1, null, new GregorianCalendar(2010, Calendar.APRIL, 17).getTime(), 100000L, 200000L, 100000L, "effort 1", false, "540", user3); effort5 = new Effort(titaTask2, null, new GregorianCalendar(2010, Calendar.APRIL, 17).getTime(), 100000L, 200000L, 100000L, "effort 1", false, "540", user3); effort6 = new Effort(titaTask3, null, new GregorianCalendar(2010, Calendar.APRIL, 17).getTime(), 100000L, 200000L, 100000L, "effort 1", false, "540", user3); // user4 - issuetrackertask 4, 5, 6, 7, 8 titatask 1, 2, 3 effort7 = new Effort(null, task4, new GregorianCalendar(2010, Calendar.APRIL, 17).getTime(), 100000L, 200000L, 100000L, "effort 1", false, "540", user4); effort8 = new Effort(null, task5, new GregorianCalendar(2010, Calendar.APRIL, 17).getTime(), 100000L, 200000L, 100000L, "effort 1", false, "540", user4); effort9 = new Effort(null, task6, new GregorianCalendar(2010, Calendar.APRIL, 17).getTime(), 100000L, 200000L, 100000L, "effort 1", false, "540", user4); effort10 = new Effort(null, task7, new GregorianCalendar(2010, Calendar.APRIL, 17).getTime(), 100000L, 200000L, 100000L, "effort 1", false, "540", user4); effort11 = new Effort(null, task8, new GregorianCalendar(2010, Calendar.APRIL, 17).getTime(), 100000L, 200000L, 100000L, "effort 1", false, "540", user4); effort12 = new Effort(titaTask1, null, new GregorianCalendar(2010, Calendar.APRIL, 17).getTime(), 100000L, 200000L, 100000L, "effort 1", false, "540", user4); effort13 = new Effort(titaTask2, null, new GregorianCalendar(2010, Calendar.APRIL, 17).getTime(), 100000L, 200000L, 100000L, "effort 1", false, "540", user4); effort14 = new Effort(titaTask4, null, new GregorianCalendar(2010, Calendar.APRIL, 17).getTime(), 100000L, 200000L, 100000L, "effort 1", false, "540", user4); // user5 - issuetrackertask 1, 2, 6, 7, 8 titatask 4, 5, 6 effort15 = new Effort(null, task1, new GregorianCalendar(2010, Calendar.APRIL, 17).getTime(), 100000L, 200000L, 100000L, "effort 1", false, "540", user5); effort16 = new Effort(null, task2, new GregorianCalendar(2010, Calendar.APRIL, 17).getTime(), 100000L, 200000L, 100000L, "effort 1", false, "540", user5); effort17 = new Effort(null, task6, new GregorianCalendar(2010, Calendar.APRIL, 17).getTime(), 100000L, 200000L, 100000L, "effort 1", false, "540", user5); effort18 = new Effort(null, task7, new GregorianCalendar(2010, Calendar.APRIL, 17).getTime(), 100000L, 200000L, 100000L, "effort 1", false, "540", user5); effort19 = new Effort(null, task8, new GregorianCalendar(2010, Calendar.APRIL, 17).getTime(), 100000L, 200000L, 100000L, "effort 1", false, "540", user5); effort20 = new Effort(titaTask4, null, new GregorianCalendar(2010, Calendar.APRIL, 17).getTime(), 100000L, 200000L, 100000L, "effort 1", false, "540", user5); effort21 = new Effort(titaTask5, null, new GregorianCalendar(2010, Calendar.APRIL, 17).getTime(), 100000L, 200000L, 100000L, "effort 1", false, "540", user5); effort22 = new Effort(titaTask6, null, new GregorianCalendar(2010, Calendar.APRIL, 17).getTime(), 100000L, 200000L, 100000L, "effort 1", false, "540", user5); // user5 - issuetrackertask 1 titatask 7, 8 effort23 = new Effort(null, task1, new GregorianCalendar(2010, Calendar.APRIL, 17).getTime(), 100000L, 200000L, 100000L, "effort 1", false, "540", user6); effort24 = new Effort(titaTask7, null, new GregorianCalendar(2010, Calendar.APRIL, 17).getTime(), 100000L, 200000L, 100000L, "effort 1", false, "540", user6); effort25 = new Effort(titaTask8, null, new GregorianCalendar(2010, Calendar.APRIL, 17).getTime(), 100000L, 200000L, 100000L, "effort 1", false, "540", user6); timeEffortDao.save(effort1);//w w w .j a v a 2 s .c o m timeEffortDao.save(effort2); timeEffortDao.save(effort3); timeEffortDao.save(effort4); timeEffortDao.save(effort5); timeEffortDao.save(effort6); timeEffortDao.save(effort7); timeEffortDao.save(effort8); timeEffortDao.save(effort9); timeEffortDao.save(effort10); timeEffortDao.save(effort11); timeEffortDao.save(effort12); timeEffortDao.save(effort13); timeEffortDao.save(effort14); timeEffortDao.save(effort15); timeEffortDao.save(effort16); timeEffortDao.save(effort17); timeEffortDao.save(effort18); timeEffortDao.save(effort19); timeEffortDao.save(effort20); timeEffortDao.save(effort21); timeEffortDao.save(effort22); timeEffortDao.save(effort23); timeEffortDao.save(effort24); timeEffortDao.save(effort25); }
From source file:cn.mljia.common.notify.utils.DateUtils.java
/** * ?/* ww w . ja v a2 s . c o m*/ * * @param date * @return */ public static Date[] getSeasonDate(Date date) { Date[] season = new Date[3]; Calendar c = Calendar.getInstance(); c.setTime(date); int nSeason = getSeason(date); if (nSeason == 1) {// c.set(Calendar.MONTH, Calendar.JANUARY); season[0] = c.getTime(); c.set(Calendar.MONTH, Calendar.FEBRUARY); season[1] = c.getTime(); c.set(Calendar.MONTH, Calendar.MARCH); season[2] = c.getTime(); } else if (nSeason == 2) {// c.set(Calendar.MONTH, Calendar.APRIL); season[0] = c.getTime(); c.set(Calendar.MONTH, Calendar.MAY); season[1] = c.getTime(); c.set(Calendar.MONTH, Calendar.JUNE); season[2] = c.getTime(); } else if (nSeason == 3) {// c.set(Calendar.MONTH, Calendar.JULY); season[0] = c.getTime(); c.set(Calendar.MONTH, Calendar.AUGUST); season[1] = c.getTime(); c.set(Calendar.MONTH, Calendar.SEPTEMBER); season[2] = c.getTime(); } else if (nSeason == 4) {// c.set(Calendar.MONTH, Calendar.OCTOBER); season[0] = c.getTime(); c.set(Calendar.MONTH, Calendar.NOVEMBER); season[1] = c.getTime(); c.set(Calendar.MONTH, Calendar.DECEMBER); season[2] = c.getTime(); } return season; }
From source file:cn.mljia.common.notify.utils.DateUtils.java
/** * /*from w ww . j a va2s . c o m*/ * 1 2 3 4 * * @param date * @return */ public static int getSeason(Date date) { int season = 0; Calendar c = Calendar.getInstance(); c.setTime(date); int month = c.get(Calendar.MONTH); switch (month) { case Calendar.JANUARY: case Calendar.FEBRUARY: case Calendar.MARCH: season = 1; break; case Calendar.APRIL: case Calendar.MAY: case Calendar.JUNE: season = 2; break; case Calendar.JULY: case Calendar.AUGUST: case Calendar.SEPTEMBER: season = 3; break; case Calendar.OCTOBER: case Calendar.NOVEMBER: case Calendar.DECEMBER: season = 4; break; default: break; } return season; }
From source file:org.kuali.kfs.module.endow.document.service.impl.CurrentTaxLotServiceImpl.java
/** * This method will check the current month and set the calendar to that month * //from w w w.j av a 2 s . com * @param month month to set the calendar, currentDate currentDate * @return calendar calendar is set to the month selected */ protected Calendar setCaledarWithMonth(String month, Date lastPaymentDate) { Calendar calendar = Calendar.getInstance(); calendar.setTime(lastPaymentDate); 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; }