Java Code Examples for java.util.Calendar#MARCH
The following examples show how to use
java.util.Calendar#MARCH .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SUtils.java From SublimePicker with Apache License 2.0 | 6 votes |
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: throw new IllegalArgumentException("Invalid Month"); } }
Example 2
Source File: Utils.java From cathode with Apache License 2.0 | 6 votes |
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: return (year % 4 == 0) ? 29 : 28; default: throw new IllegalArgumentException("Invalid Month"); } }
Example 3
Source File: Utils.java From BottomSheetPickers with Apache License 2.0 | 6 votes |
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: return (year % 4 == 0) ? 29 : 28; default: throw new IllegalArgumentException("Invalid Month"); } }
Example 4
Source File: Utils.java From narrate-android with Apache License 2.0 | 6 votes |
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: return (year % 4 == 0) ? 29 : 28; default: throw new IllegalArgumentException("Invalid Month"); } }
Example 5
Source File: CalendarUtils.java From AirCalendar with MIT License | 6 votes |
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: return ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) ? 28 : 29; default: throw new IllegalArgumentException("Invalid Month"); } }
Example 6
Source File: AppCompatDatePickerDelegate.java From AppCompat-Extension-Library with Apache License 2.0 | 6 votes |
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: return (year % 4 == 0) ? 29 : 28; default: throw new IllegalArgumentException("Invalid Month"); } }
Example 7
Source File: CalendarUtils.java From UltimateAndroid with Apache License 2.0 | 6 votes |
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: return (year % 4 == 0) ? 29 : 28; default: throw new IllegalArgumentException("Invalid Month"); } }
Example 8
Source File: BillingServiceBeanIT.java From development with Apache License 2.0 | 5 votes |
@Test public void testMigrationBeginOfMarch() throws Exception { final int testMonth = Calendar.MARCH; final int testDay = 1; final BigDecimal price = new BigDecimal("12598.72"); testMigrationBase(testYear, testMonth, testDay, price); xmlValidator.validateBillingResultXML(); }
Example 9
Source File: SimpleTimeZoneTest.java From j2objc with Apache License 2.0 | 5 votes |
public void testDstNewYork2014_2ndSundayMarch_1stSundayNovember_StandardTime() { TimeZone timeZone = new SimpleTimeZone(NEW_YORK_RAW_OFFSET, "EST", Calendar.MARCH, 2, Calendar.SUNDAY, 7200000, SimpleTimeZone.STANDARD_TIME, Calendar.NOVEMBER, 1, Calendar.SUNDAY, 3600000, SimpleTimeZone.STANDARD_TIME, 3600000); checkDstNewYork2014(timeZone); }
Example 10
Source File: UmmalquraGregorianConverterTests.java From ummalqura-calendar with MIT License | 5 votes |
@Test public void gregorianToHijri1() { Calendar cal = new GregorianCalendar(2015, Calendar.MARCH, 14); int[] hDateInfo = UmmalquraGregorianConverter.toHijri(cal.getTime()); assertTrue("2015-03-14 G should be 1436-05-23 H", hDateInfo[0] == 1436 && hDateInfo[1] == 4 && hDateInfo[2] == 23); }
Example 11
Source File: BillingServiceBeanIT.java From development with Apache License 2.0 | 5 votes |
@Test public void testInterruptedPeriodWithManyEventsBeginOfMarch() throws Exception { final int testMonth = Calendar.MARCH; final int testDay = 1; final BigDecimal etalonPrice = new BigDecimal("2147.5942460317"); testInterruptedPeriodWithManyEventsBase(testMonth, testDay, etalonPrice); xmlValidator.validateBillingResultXML(); }
Example 12
Source File: HttpDateTime.java From android-download-manager with Apache License 2.0 | 5 votes |
private static int getMonth(String monthString) { int hash = Character.toLowerCase(monthString.charAt(0)) + Character.toLowerCase(monthString.charAt(1)) + Character.toLowerCase(monthString.charAt(2)) - 3 * 'a'; switch (hash) { case 22: return Calendar.JANUARY; case 10: return Calendar.FEBRUARY; case 29: return Calendar.MARCH; case 32: return Calendar.APRIL; case 36: return Calendar.MAY; case 42: return Calendar.JUNE; case 40: return Calendar.JULY; case 26: return Calendar.AUGUST; case 37: return Calendar.SEPTEMBER; case 35: return Calendar.OCTOBER; case 48: return Calendar.NOVEMBER; case 9: return Calendar.DECEMBER; default: throw new IllegalArgumentException(); } }
Example 13
Source File: Kits.java From XDroidMvp with MIT License | 5 votes |
/** * 获取月份的天数 * * @param mills * @return */ public static int getDaysInMonth(long mills) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(mills); int year = calendar.get(Calendar.YEAR); int month = calendar.get(Calendar.MONTH); 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: throw new IllegalArgumentException("Invalid Month"); } }
Example 14
Source File: SimpleTimeZoneTest.java From j2objc with Apache License 2.0 | 5 votes |
public void testDstNewYork2014_9thMarch_2ndNovember_StandardTime() { TimeZone timeZone = new SimpleTimeZone(NEW_YORK_RAW_OFFSET, "EST", Calendar.MARCH, 9, 0, 7200000, SimpleTimeZone.STANDARD_TIME, Calendar.NOVEMBER, 2, 0, 3600000, SimpleTimeZone.STANDARD_TIME, 3600000); checkDstNewYork2014(timeZone); }
Example 15
Source File: BillingServiceBeanIT.java From development with Apache License 2.0 | 5 votes |
@Test public void testInterruptedPeriodBeginOfMarch() throws Exception { final int testMonth = Calendar.MARCH; final int testDay = 1; final BigDecimal etalonPrice = new BigDecimal("654.7619047619"); testInterruptedPeriod(testMonth, testDay, P_1_ID, false, etalonPrice); xmlValidator.validateBillingResultXML(); }
Example 16
Source File: WorkCalendarHelper.java From Open-Lowcode with Eclipse Public License 2.0 | 5 votes |
private int getMonthInCalendar(ChoiceValue<WesternmonthsChoiceDefinition> month) { if (month.equals(WesternmonthsChoiceDefinition.get().M01)) return Calendar.JANUARY; if (month.equals(WesternmonthsChoiceDefinition.get().M02)) return Calendar.FEBRUARY; if (month.equals(WesternmonthsChoiceDefinition.get().M03)) return Calendar.MARCH; if (month.equals(WesternmonthsChoiceDefinition.get().M04)) return Calendar.APRIL; if (month.equals(WesternmonthsChoiceDefinition.get().M05)) return Calendar.MAY; if (month.equals(WesternmonthsChoiceDefinition.get().M06)) return Calendar.JUNE; if (month.equals(WesternmonthsChoiceDefinition.get().M07)) return Calendar.JULY; if (month.equals(WesternmonthsChoiceDefinition.get().M08)) return Calendar.AUGUST; if (month.equals(WesternmonthsChoiceDefinition.get().M09)) return Calendar.SEPTEMBER; if (month.equals(WesternmonthsChoiceDefinition.get().M10)) return Calendar.OCTOBER; if (month.equals(WesternmonthsChoiceDefinition.get().M11)) return Calendar.NOVEMBER; if (month.equals(WesternmonthsChoiceDefinition.get().M12)) return Calendar.DECEMBER; return -1; }
Example 17
Source File: TestPropertyValue.java From dolphin-platform with Apache License 2.0 | 4 votes |
@Test public void testWithComplexDataTypesModel(@Mocked AbstractClientConnector connector) { final Calendar date1 = new GregorianCalendar(2016, Calendar.MARCH, 1, 0, 1, 2); date1.set(Calendar.MILLISECOND, 3); date1.setTimeZone(TimeZone.getTimeZone("GMT+2:00")); final Calendar date2 = new GregorianCalendar(2016, Calendar.FEBRUARY, 29, 0, 1, 2); date2.set(Calendar.MILLISECOND, 3); date2.setTimeZone(TimeZone.getTimeZone("UTC")); final ClientModelStore clientModelStore = createClientModelStore(connector); final EventDispatcher dispatcher = createEventDispatcher(clientModelStore); final BeanRepository repository = createBeanRepository(clientModelStore, dispatcher); final BeanManager manager = createBeanManager(clientModelStore, repository, dispatcher); ComplexDataTypesModel model = manager.create(ComplexDataTypesModel.class); PresentationModel dolphinModel = clientModelStore.findAllPresentationModelsByType(ComplexDataTypesModel.class.getName()).get(0); Attribute dateAttribute = dolphinModel.getAttribute("dateProperty"); assertThat(dateAttribute.getValue(), nullValue()); model.getDateProperty().set(date1.getTime()); assertThat(dateAttribute.getValue().toString(), is("2016-02-29T22:01:02.003Z")); assertThat(model.getDateProperty().get(), is(date1.getTime())); dateAttribute.setValue("2016-02-29T00:01:02.003Z"); assertThat(dateAttribute.getValue().toString(), is("2016-02-29T00:01:02.003Z")); assertThat(model.getDateProperty().get(), is(date2.getTime())); Attribute calendarAttribute = dolphinModel.getAttribute("calendarProperty"); assertThat(calendarAttribute.getValue(), nullValue()); model.getCalendarProperty().set(date1); assertThat(calendarAttribute.getValue().toString(), is("2016-02-29T22:01:02.003Z")); assertThat(model.getCalendarProperty().get().getTimeInMillis(), is(date1.getTimeInMillis())); calendarAttribute.setValue("2016-02-29T00:01:02.003Z"); assertThat(calendarAttribute.getValue().toString(), is("2016-02-29T00:01:02.003Z")); assertThat(model.getCalendarProperty().get(), is(date2)); Attribute enumAttribute = dolphinModel.getAttribute("enumProperty"); assertThat(enumAttribute.getValue(), nullValue()); model.getEnumProperty().set(VALUE_1); assertThat(enumAttribute.getValue().toString(), is("VALUE_1")); assertThat(model.getEnumProperty().get(), is(VALUE_1)); enumAttribute.setValue("VALUE_2"); assertThat(enumAttribute.getValue().toString(), is("VALUE_2")); assertThat(model.getEnumProperty().get(), is(VALUE_2)); }
Example 18
Source File: Utils.java From Birdays with Apache License 2.0 | 4 votes |
/** * Returns zodiac name of certain date */ public static int getZodiacId(long date) { int resId = 0; dayOfBirthday.setTimeInMillis(date); switch (getMonth(dayOfBirthday)) { case Calendar.JANUARY: resId = getDay(dayOfBirthday) < 21 ? R.string.capricorn : R.string.aquarius; break; case Calendar.FEBRUARY: resId = getDay(dayOfBirthday) < 20 ? R.string.aquarius : R.string.pisces; break; case Calendar.MARCH: resId = getDay(dayOfBirthday) < 21 ? R.string.pisces : R.string.aries; break; case Calendar.APRIL: resId = getDay(dayOfBirthday) < 21 ? R.string.aries : R.string.taurus; break; case Calendar.MAY: resId = getDay(dayOfBirthday) < 22 ? R.string.taurus : R.string.gemini; break; case Calendar.JUNE: resId = getDay(dayOfBirthday) < 22 ? R.string.gemini : R.string.cancer; break; case Calendar.JULY: resId = getDay(dayOfBirthday) < 23 ? R.string.cancer : R.string.leo; break; case Calendar.AUGUST: resId = getDay(dayOfBirthday) < 23 ? R.string.leo : R.string.virgo; break; case Calendar.SEPTEMBER: resId = getDay(dayOfBirthday) < 24 ? R.string.virgo : R.string.libra; break; case Calendar.OCTOBER: resId = getDay(dayOfBirthday) < 24 ? R.string.libra : R.string.scorpio; break; case Calendar.NOVEMBER: resId = getDay(dayOfBirthday) < 23 ? R.string.scorpio : R.string.sagittarius; break; case Calendar.DECEMBER: resId = getDay(dayOfBirthday) < 22 ? R.string.sagittarius : R.string.capricorn; break; } return resId; }
Example 19
Source File: MultiCalendarAdapter.java From holo-calendar with Apache License 2.0 | 4 votes |
/** * Get the title for the current position * * @param position - The position in the ViewPager * @return Title: MONTH YEAR -> MARCH 2013 */ @Override public String getTitle(final int position) { final Context context = mContext; final Calendar date = Calendar.getInstance(); date.setTimeInMillis((mCalendarView.getFirstValidDay().getTimeInMillis())); date.add(Calendar.MONTH, position); final String month; switch(date.get(Calendar.MONTH)) { case Calendar.JANUARY: month = context.getString(R.string.lib_month_january); break; case Calendar.FEBRUARY: month = context.getString(R.string.lib_month_february); break; case Calendar.MARCH: month = context.getString(R.string.lib_month_march); break; case Calendar.APRIL: month = context.getString(R.string.lib_month_april); break; case Calendar.MAY: month = context.getString(R.string.lib_month_may); break; case Calendar.JUNE: month = context.getString(R.string.lib_month_june); break; case Calendar.JULY: month = context.getString(R.string.lib_month_july); break; case Calendar.AUGUST: month = context.getString(R.string.lib_month_august); break; case Calendar.SEPTEMBER: month = context.getString(R.string.lib_month_september); break; case Calendar.OCTOBER: month = context.getString(R.string.lib_month_october); break; case Calendar.NOVEMBER: month = context.getString(R.string.lib_month_november); break; default: case Calendar.DECEMBER: month = context.getString(R.string.lib_month_december); break; } return month + " " + date.get(Calendar.YEAR); }
Example 20
Source File: FunnyEasterEgg.java From QuickShop-Reremake with GNU General Public License v3.0 | 4 votes |
private boolean easterDay() { int year = new Date().getYear(); int a = year % 19, b = year / 100, c = year % 100, d = b / 4, e = b % 4, g = (8 * b + 13) / 25, h = (19 * a + b - d - g + 15) % 30, j = c / 4, k = c % 4, m = (a + 11 * h) / 319, r = (2 * e + 2 * j - k - h + m + 32) % 7, n = (h - m + r + 90) / 25, p = (h - m + r + n + 19) % 32; int result; switch (n) { case 1: result = Calendar.JANUARY; break; case 2: result = Calendar.FEBRUARY; break; case 3: result = Calendar.MARCH; break; case 4: result = Calendar.APRIL; break; case 5: result = Calendar.MAY; break; case 6: result = Calendar.JUNE; break; case 7: result = Calendar.JULY; break; case 8: result = Calendar.AUGUST; break; case 9: result = Calendar.SEPTEMBER; break; case 10: result = Calendar.OCTOBER; break; case 11: result = Calendar.NOVEMBER; break; case 12: result = Calendar.DECEMBER; break; default: throw new IllegalStateException("Unexpected value: " + n); } Date eaterDay = new Date(year, result, p); Date currentDate = new Date(System.currentTimeMillis()); if (currentDate.getYear() == eaterDay.getYear()) { if (currentDate.getMonth() == eaterDay.getMonth()) { return currentDate.getDay() == eaterDay.getDay(); } } return false; }