Java Code Examples for java.util.Calendar#JUNE
The following examples show how to use
java.util.Calendar#JUNE .
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: 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 2
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 3
Source File: Utils.java From StyleableDateTimePicker 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) ? 29 : 28; default: throw new IllegalArgumentException("Invalid Month"); } }
Example 4
Source File: Utils.java From Conquer 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: 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 6
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 7
Source File: Util.java From whyline with MIT License | 6 votes |
public static String getMonthString(int month) { switch(month) { case Calendar.JANUARY : return "January"; case Calendar.FEBRUARY : return "February"; case Calendar.MARCH : return "March"; case Calendar.APRIL : return "April"; case Calendar.MAY : return "May"; case Calendar.JUNE : return "June"; case Calendar.JULY : return "July"; case Calendar.AUGUST : return "August"; case Calendar.SEPTEMBER : return "September"; case Calendar.OCTOBER : return "October"; case Calendar.NOVEMBER : return "November"; case Calendar.DECEMBER : return "December"; default : return "invalid month"; } }
Example 8
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 9
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 10
Source File: UpcomingWeekendsActivity.java From Travel-Mate with MIT License | 5 votes |
private int getMonthByString(String month) { switch (month) { case "January": return Calendar.JANUARY; case "February": return Calendar.FEBRUARY; case "March": return Calendar.MARCH; case "April": return Calendar.APRIL; case "May": return Calendar.MAY; case "June": return Calendar.JUNE; case "July": return Calendar.JULY; case "August": return Calendar.AUGUST; case "September": return Calendar.SEPTEMBER; case "October": return Calendar.OCTOBER; case "November": return Calendar.NOVEMBER; case "December": return Calendar.DECEMBER; } return -1; }
Example 11
Source File: HttpDateTime.java From play-apk-expansion 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 12
Source File: DateUtils.java From mumu with Apache License 2.0 | 5 votes |
/** * * 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; }
Example 13
Source File: EarthClock.java From mars-sim with GNU General Public License v3.0 | 5 votes |
public String getMonthString() { int w = getMonth(); StringBuilder s = new StringBuilder(); if (w == Calendar.JANUARY) s.append("Jan"); else if (w == Calendar.FEBRUARY) s.append("Feb"); else if (w == Calendar.MARCH) s.append("Mar"); else if (w == Calendar.APRIL) s.append("Apr"); else if (w == Calendar.MAY) s.append("May"); else if (w == Calendar.JUNE) s.append("Jun"); else if (w == Calendar.JULY) s.append("Jul"); else if (w == Calendar.AUGUST) s.append("Aug"); else if (w == Calendar.SEPTEMBER) s.append("Sep"); else if (w == Calendar.OCTOBER) s.append("Oct"); else if (w == Calendar.NOVEMBER) s.append("Nov"); else if (w == Calendar.DECEMBER) s.append("Dec"); return s.toString(); }
Example 14
Source File: DateUtils.java From android-utils with MIT License | 4 votes |
/** * Gets abbreviated name of the month from the given date. * * @param date ISO format date * @return Returns the name of the month */ public static String getMonthAbbreviated(String date) { Date dateDT = parseDate(date); if (dateDT == null) { return null; } // Get current date Calendar c = Calendar.getInstance(); // it is very important to // set the date of // the calendar. c.setTime(dateDT); int day = c.get(Calendar.MONTH); String dayStr = null; switch (day) { case Calendar.JANUARY: dayStr = "Jan"; break; case Calendar.FEBRUARY: dayStr = "Feb"; break; case Calendar.MARCH: dayStr = "Mar"; break; case Calendar.APRIL: dayStr = "Apr"; break; case Calendar.MAY: dayStr = "May"; break; case Calendar.JUNE: dayStr = "Jun"; break; case Calendar.JULY: dayStr = "Jul"; break; case Calendar.AUGUST: dayStr = "Aug"; break; case Calendar.SEPTEMBER: dayStr = "Sep"; break; case Calendar.OCTOBER: dayStr = "Oct"; break; case Calendar.NOVEMBER: dayStr = "Nov"; break; case Calendar.DECEMBER: dayStr = "Dec"; break; } return dayStr; }
Example 15
Source File: monthConverter.java From openbd-core with GNU General Public License v3.0 | 4 votes |
/** * takes a month and returns the index of it - JAN => 1, FEB => 2... * assumes byte[] is in lower case * returns -1 if an invalid month. */ public static int convertMonthToInt(char[] month){ switch (month[0]){ case 'j': if (equivalent(month, "january")){ return Calendar.JANUARY; } else if (equivalent(month, "june")){ return Calendar.JUNE; } else if (equivalent(month, "july")){ return Calendar.JULY; } else return -1; case 'M': case 'm': if (equivalent(month, "may")){ return Calendar.MAY; } else if (equivalent(month, "march")){ return Calendar.MARCH; } else return -1; case 'A': case 'a': if (equivalent(month, "april")){ return Calendar.APRIL; } else if (equivalent(month, "august")){ return Calendar.AUGUST; } else return -1; case 'F': case 'f': if (equivalent(month, "february")){ return Calendar.FEBRUARY; } else return -1; case 'D': case 'd': if (equivalent(month, "december")){ return Calendar.DECEMBER; } else return -1; case 'S': case 's': if (equivalent(month, "september")){ return Calendar.SEPTEMBER; } else return -1; case 'O': case 'o': if (equivalent(month, "october")){ return Calendar.OCTOBER; } else return -1; case 'N': case 'n': if (equivalent(month, "november")){ return Calendar.NOVEMBER; } else return -1; default: return -1; }//switch }
Example 16
Source File: TimeConstraint.java From hawkular-alerts with Apache License 2.0 | 4 votes |
private int month(String sMonth) { if (isEmpty(sMonth)) { return -1; } if (sMonth.length() < 3) { return -1; } String prefix = sMonth.substring(0, 3).toLowerCase(); MONTH m = MONTH.fromString(prefix); if (m == null) { return -1; } switch (m) { case JANUARY: return Calendar.JANUARY; case FEBRUARY: return Calendar.FEBRUARY; case MARCH: return Calendar.MARCH; case APRIL: return Calendar.APRIL; case MAY: return Calendar.MAY; case JUNE: return Calendar.JUNE; case JULY: return Calendar.JULY; case AUGUST: return Calendar.AUGUST; case SEPTEMBER: return Calendar.SEPTEMBER; case OCTOBER: return Calendar.OCTOBER; case NOVEMBER: return Calendar.NOVEMBER; case DECEMBER: return Calendar.DECEMBER; default: return -1; } }
Example 17
Source File: AllFragment.java From Birdays with Apache License 2.0 | 4 votes |
private Separator getSeparator(Person person) { Separator separator = null; switch (person.getMonth()) { case Calendar.JANUARY: if (!adapter.containsSeparatorJanuary) { adapter.containsSeparatorJanuary = true; separator = new Separator(Separator.TYPE_JANUARY); } break; case Calendar.FEBRUARY: if (!adapter.containsSeparatorFebruary) { adapter.containsSeparatorFebruary = true; separator = new Separator(Separator.TYPE_FEBRUARY); } break; case Calendar.MARCH: if (!adapter.containsSeparatorMarch) { adapter.containsSeparatorMarch = true; separator = new Separator(Separator.TYPE_MARCH); } break; case Calendar.APRIL: if (!adapter.containsSeparatorApril) { adapter.containsSeparatorApril = true; separator = new Separator(Separator.TYPE_APRIL); } break; case Calendar.MAY: if (!adapter.containsSeparatorMay) { adapter.containsSeparatorMay = true; separator = new Separator(Separator.TYPE_MAY); } break; case Calendar.JUNE: if (!adapter.containsSeparatorJune) { adapter.containsSeparatorJune = true; separator = new Separator(Separator.TYPE_JUNE); } break; case Calendar.JULY: if (!adapter.containsSeparatorJuly) { adapter.containsSeparatorJuly = true; separator = new Separator(Separator.TYPE_JULY); } break; case Calendar.AUGUST: if (!adapter.containsSeparatorAugust) { adapter.containsSeparatorAugust = true; separator = new Separator(Separator.TYPE_AUGUST); } break; case Calendar.SEPTEMBER: if (!adapter.containsSeparatorSeptember) { adapter.containsSeparatorSeptember = true; separator = new Separator(Separator.TYPE_SEPTEMBER); } break; case Calendar.OCTOBER: if (!adapter.containsSeparatorOctober) { adapter.containsSeparatorOctober = true; separator = new Separator(Separator.TYPE_OCTOBER); } break; case Calendar.NOVEMBER: if (!adapter.containsSeparatorNovember) { adapter.containsSeparatorNovember = true; separator = new Separator(Separator.TYPE_NOVEMBER); } break; case Calendar.DECEMBER: if (!adapter.containsSeparatorDecember) { adapter.containsSeparatorDecember = true; separator = new Separator(Separator.TYPE_DECEMBER); } break; } return separator; }
Example 18
Source File: ISO8601DateFormat.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
/** Appends a date in the format "YYYY-mm-dd HH:mm:ss,SSS" to <code>sbuf</code>. For example: "1999-11-27 15:49:37,459". @param sbuf the <code>StringBuffer</code> to write to */ public StringBuffer format(Date date, StringBuffer sbuf, FieldPosition fieldPosition) { long now = date.getTime(); int millis = (int)(now % 1000); if ((now - millis) != lastTime) { // We reach this point at most once per second // across all threads instead of each time format() // is called. This saves considerable CPU time. calendar.setTime(date); int start = sbuf.length(); int year = calendar.get(Calendar.YEAR); sbuf.append(year); String month; switch(calendar.get(Calendar.MONTH)) { case Calendar.JANUARY: month = "-01-"; break; case Calendar.FEBRUARY: month = "-02-"; break; case Calendar.MARCH: month = "-03-"; break; case Calendar.APRIL: month = "-04-"; break; case Calendar.MAY: month = "-05-"; break; case Calendar.JUNE: month = "-06-"; break; case Calendar.JULY: month = "-07-"; break; case Calendar.AUGUST: month = "-08-"; break; case Calendar.SEPTEMBER: month = "-09-"; break; case Calendar.OCTOBER: month = "-10-"; break; case Calendar.NOVEMBER: month = "-11-"; break; case Calendar.DECEMBER: month = "-12-"; break; default: month = "-NA-"; break; } sbuf.append(month); int day = calendar.get(Calendar.DAY_OF_MONTH); if(day < 10) sbuf.append('0'); sbuf.append(day); sbuf.append(' '); int hour = calendar.get(Calendar.HOUR_OF_DAY); if(hour < 10) { sbuf.append('0'); } sbuf.append(hour); sbuf.append(':'); int mins = calendar.get(Calendar.MINUTE); if(mins < 10) { sbuf.append('0'); } sbuf.append(mins); sbuf.append(':'); int secs = calendar.get(Calendar.SECOND); if(secs < 10) { sbuf.append('0'); } sbuf.append(secs); sbuf.append(','); // store the time string for next time to avoid recomputation sbuf.getChars(start, sbuf.length(), lastTimeString, 0); lastTime = now - millis; } else { sbuf.append(lastTimeString); } if (millis < 100) sbuf.append('0'); if (millis < 10) sbuf.append('0'); sbuf.append(millis); return sbuf; }
Example 19
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; }
Example 20
Source File: Monthname.java From tddl5 with Apache License 2.0 | 4 votes |
@Override public Object compute(Object[] args, ExecutionContext ec) { for (Object arg : args) { if (ExecUtils.isNull(arg)) { return null; } } java.sql.Timestamp timestamp = DataType.TimestampType.convertFrom(args[0]); Calendar cal = Calendar.getInstance(); cal.setTime(timestamp); int monthName = cal.get(Calendar.MONTH); switch (monthName) { case Calendar.JANUARY: return "January"; case Calendar.FEBRUARY: return "February"; case Calendar.MARCH: return "March"; case Calendar.APRIL: return "April"; case Calendar.MAY: return "May"; case Calendar.JUNE: return "June"; case Calendar.JULY: return "July"; case Calendar.AUGUST: return "August"; case Calendar.SEPTEMBER: return "September"; case Calendar.OCTOBER: return "October"; case Calendar.NOVEMBER: return "November"; case Calendar.DECEMBER: return "December"; default: return "Undecimber"; } }