List of usage examples for java.util Calendar OCTOBER
int OCTOBER
To view the source code for java.util Calendar OCTOBER.
Click Source Link
From source file:com.appeaser.sublimepickerlibrary.utilities.SUtils.java
public static int getDaysInMonth(int month, int year) { switch (month) { case Calendar.JANUARY: case Calendar.MARCH: case Calendar.MAY: case Calendar.JULY: case Calendar.AUGUST: case Calendar.OCTOBER: case Calendar.DECEMBER: return 31; case Calendar.APRIL: case Calendar.JUNE: case Calendar.SEPTEMBER: case Calendar.NOVEMBER: return 30; case Calendar.FEBRUARY: // This is not correct. See isLeapYear(int) above //return (year % 4 == 0) ? 29 : 28; return isLeapYear(year) ? 29 : 28; default:/*from ww w .j a v a2 s . co m*/ throw new IllegalArgumentException("Invalid Month"); } }
From source file:org.openmrs.module.radiology.web.controller.PortletsControllerTest.java
/** * @see PortletsController#isEndDateBeforeStartDate(Date, Date) * @verifies return false if end date is not after start date *//*w w w . j av a 2s. c om*/ @Test public void isEndDateBeforeStartDate_shouldReturnFalseIfEndDateIsNotAfterStartDate() throws Exception { Method isEndDateBeforeStartDateMethod = portletsController.getClass().getDeclaredMethod( "isEndDateBeforeStartDate", new Class[] { java.util.Date.class, java.util.Date.class }); isEndDateBeforeStartDateMethod.setAccessible(true); Date startDate = new GregorianCalendar(2001, Calendar.JANUARY, 01).getTime(); Date endDate = new GregorianCalendar(2010, Calendar.OCTOBER, 10).getTime(); Boolean isEndDateBeforeStartDate = (Boolean) isEndDateBeforeStartDateMethod.invoke(portletsController, new Object[] { startDate, endDate }); assertThat(isEndDateBeforeStartDate, is(false)); }
From source file:com.lloydtorres.stately.helpers.RaraHelper.java
/** * Determines if the current day in the EST/EDT timezone is a special day. * @return The special day mode/*from ww w .j a v a 2s.c o m*/ */ public static int getSpecialDayStatus() { Calendar cal = new GregorianCalendar(); cal.setTimeZone(SparkleHelper.TIMEZONE_TORONTO); int month = cal.get(Calendar.MONTH); int day = cal.get(Calendar.DAY_OF_MONTH); if (month == Calendar.JANUARY && day == 30) { return DAY_STATELY_BIRTHDAY; } else if (month == Calendar.JULY && day == 1) { return DAY_CANADA_DAY; } else if (month == Calendar.OCTOBER && day == 31) { return DAY_HALLOWEEN; } else if (month == Calendar.NOVEMBER && day == 13) { return DAY_NS_BIRTHDAY; } else { return DAY_NORMAL; } }
From source file:ch.cyberduck.core.ftp.parser.UnixFTPEntryParserTest.java
@Test public void testMVSParser() { FTPFileEntryParser parser = new FTPParserSelector() .getParser("MVS is the operating system of this server. FTP Server is running on z/OS."); FTPFile parsed;/*from www .j a v a2 s .c om*/ final String entry = "drwxr-xr-x 6 START2 SYS1 8192 Oct 28 2008 ADCD"; parser.preParse(new ArrayList<String>(Arrays.asList("total 66", entry))); // #7717 parsed = parser.parseFTPEntry(entry); assertNotNull(parsed); assertEquals("ADCD", parsed.getName()); assertEquals("START2", parsed.getUser()); assertEquals("SYS1", parsed.getGroup()); assertNotNull(parsed.getTimestamp()); assertEquals(Calendar.OCTOBER, parsed.getTimestamp().get(Calendar.MONTH)); assertEquals(28, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH)); assertEquals(2008, parsed.getTimestamp().get(Calendar.YEAR)); }
From source file:br.msf.commons.util.AbstractDateUtils.java
protected static Collection<Calendar> getBrasilianHolidays(final int year) { Collection<Calendar> holidays = new ArrayList<>(); // feriados fixos holidays.add(new GregorianCalendar(year, Calendar.JANUARY, 1)); // Confraternizacao Universal holidays.add(new GregorianCalendar(year, Calendar.APRIL, 21)); // Tiradentes holidays.add(new GregorianCalendar(year, Calendar.MAY, 1)); // Dia do Trabalho holidays.add(new GregorianCalendar(year, Calendar.OCTOBER, 12)); // Nossa Senhora Aparecida holidays.add(new GregorianCalendar(year, Calendar.NOVEMBER, 2)); // Finados holidays.add(new GregorianCalendar(year, Calendar.NOVEMBER, 15)); // Proclamacao da Republica holidays.add(new GregorianCalendar(year, Calendar.DECEMBER, 25)); // Natal // feriados calculados Calendar pascoa = getSundayOfEaster(year); Calendar carnaval = (Calendar) pascoa.clone(); carnaval.add(Calendar.DAY_OF_MONTH, -47); Calendar corpusChristi = (Calendar) pascoa.clone(); corpusChristi.add(Calendar.DAY_OF_MONTH, 60); holidays.add(carnaval); // Carnaval holidays.add(pascoa); // Pascoa holidays.add(corpusChristi); // Corpus Christi return holidays; }
From source file:br.ojimarcius.commons.util.AbstractDateUtils.java
protected static Collection<Calendar> getBrasilianHolidays(final int year) { Collection<Calendar> holidays = new ArrayList<Calendar>(); // feriados fixos holidays.add(new GregorianCalendar(year, Calendar.JANUARY, 1)); // Confraternizacao Universal holidays.add(new GregorianCalendar(year, Calendar.APRIL, 21)); // Tiradentes holidays.add(new GregorianCalendar(year, Calendar.MAY, 1)); // Dia do Trabalho holidays.add(new GregorianCalendar(year, Calendar.OCTOBER, 12)); // Nossa Senhora Aparecida holidays.add(new GregorianCalendar(year, Calendar.NOVEMBER, 2)); // Finados holidays.add(new GregorianCalendar(year, Calendar.NOVEMBER, 15)); // Proclamacao da Republica holidays.add(new GregorianCalendar(year, Calendar.DECEMBER, 25)); // Natal // feriados calculados Calendar pascoa = getSundayOfEaster(year); Calendar carnaval = (Calendar) pascoa.clone(); carnaval.add(Calendar.DAY_OF_MONTH, -47); Calendar corpusChristi = (Calendar) pascoa.clone(); corpusChristi.add(Calendar.DAY_OF_MONTH, 60); holidays.add(carnaval); // Carnaval holidays.add(pascoa); // Pascoa holidays.add(corpusChristi); // Corpus Christi return holidays; }
From source file:com.tr4android.support.extension.picker.date.SimpleMonthView.java
private static int getDaysInMonth(int month, int year) { switch (month) { case Calendar.JANUARY: case Calendar.MARCH: case Calendar.MAY: case Calendar.JULY: case Calendar.AUGUST: case Calendar.OCTOBER: case Calendar.DECEMBER: return 31; case Calendar.APRIL: case Calendar.JUNE: case Calendar.SEPTEMBER: case Calendar.NOVEMBER: return 30; case Calendar.FEBRUARY: return (year % 4 == 0) ? 29 : 28; default:/* w ww . j a v a2 s .c o m*/ throw new IllegalArgumentException("Invalid Month"); } }
From source file:com.lastsoft.plog.adapter.GameAdapter.java
public void playPopup(View v, final int position) { try {// w ww . jav a 2s . 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. * // ww w . ja v a 2s . 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:org.apache.logging.log4j.core.util.datetime.FastDateParserTest.java
@Test public void testLang538() throws ParseException { final DateParser parser = getInstance("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", GMT); final Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT-8")); cal.clear();/*from www. j a v a 2 s . co m*/ cal.set(2009, Calendar.OCTOBER, 16, 8, 42, 16); assertEquals(cal.getTime(), parser.parse("2009-10-16T16:42:16.000Z")); }