Java Code Examples for java.util.Calendar.JUNE

The following are Jave code examples for showing how to use JUNE of the java.util.Calendar class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: GitHub   File: Utils.java   View Source Code Vote up 7 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
Project: AirCalendar   File: CalendarUtils.java   View Source Code Vote up 7 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 3
Project: zcustomcalendar   File: ActivityMain.java   View Source Code Vote up 7 votes
@Override
public Map<Integer, Object>[] onNavigationButtonClicked(int whichButton, Calendar newMonth) {
	Map<Integer, Object>[] arr = new Map[2];
	switch(newMonth.get(Calendar.MONTH)) {
		case Calendar.AUGUST:
			arr[0] = new HashMap<>(); //This is the map linking a date to its description
			arr[0].put(3, "unavailable");
			arr[0].put(6, "holiday");
			arr[0].put(21, "unavailable");
			arr[0].put(24, "holiday");
			arr[1] = null; //Optional: This is the map linking a date to its tag.
			break;
		case Calendar.JUNE:
			arr[0] = new HashMap<>();
			arr[0].put(5, "unavailable");
			arr[0].put(10, "holiday");
			arr[0].put(19, "holiday");
			break;
	}
	return arr;
}
 
Example 4
Project: CustomizableCalendar   File: DateUtils.java   View Source Code Vote up 7 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
Project: unity-obb-downloader   File: HttpDateTime.java   View Source Code Vote up 6 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 6
Project: mumu-core   File: DateUtils.java   View Source Code Vote up 6 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 7
Project: xbin-store   File: DateUtils.java   View Source Code Vote up 6 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 8
Project: Phoenix-for-VK   File: Month.java   View Source Code Vote up 6 votes
@StringRes
public static int getMonthTitle(int num){
    switch (num){
        case Calendar.JANUARY:
            return R.string.january;
        case Calendar.FEBRUARY:
            return R.string.february;
        case Calendar.MARCH:
            return R.string.march;
        case Calendar.APRIL:
            return R.string.april;
        case Calendar.MAY:
            return R.string.may;
        case Calendar.JUNE:
            return R.string.june;
        case Calendar.JULY:
            return R.string.july;
        case Calendar.AUGUST:
            return R.string.august;
        case Calendar.SEPTEMBER:
            return R.string.september;
        case Calendar.OCTOBER:
            return R.string.october;
        case Calendar.NOVEMBER:
            return R.string.november;
        case Calendar.DECEMBER:
            return R.string.december;
    }

    throw new IllegalArgumentException();
}
 
Example 9
Project: 19porn   File: Kits.java   View Source Code Vote up 6 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 10
Project: Renrentou   File: Kits.java   View Source Code Vote up 6 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 11
Project: alfresco-repository   File: PropertyDateValueEntity.java   View Source Code Vote up 6 votes
public void setValue(Date value)
{
    long valueInMs = value.getTime();
    this.dateValue = valueInMs;
    
    Calendar cal = GregorianCalendar.getInstance();
    cal.setTimeZone(TimeZone.getTimeZone("GMT"));
    cal.setTimeInMillis(valueInMs);
    
    // We need month_of_year for further calculations
    this.monthOfYear = (short) cal.get(Calendar.MONTH);
    
    this.fullYear = (short) cal.get(Calendar.YEAR);
    this.halfOfYear = (short) monthOfYear < Calendar.JUNE ? (short)0 : (short)1;
    this.quarterOfYear = (short) (monthOfYear / (short)3);
    this.weekOfYear = (short) cal.get(Calendar.WEEK_OF_YEAR);
    this.weekOfMonth = (short) cal.get(Calendar.WEEK_OF_MONTH);
    this.dayOfYear = (short) cal.get(Calendar.DAY_OF_YEAR);
    this.dayOfMonth = (short) cal.get(Calendar.DAY_OF_MONTH);
    this.dayOfWeek = (short) cal.get(Calendar.DAY_OF_MONTH);
}
 
Example 12
Project: LightSIP   File: SIPDate.java   View Source Code Vote up 6 votes
/**
 * Set the month member
 * @param m String to set.
 * @throws IllegalArgumentException if m is not a valid month
 */
public void setMonth(String m) throws IllegalArgumentException {
    sipMonth = m;
    if (sipMonth.compareToIgnoreCase(JAN) == 0) {
        month = Calendar.JANUARY;
    } else if (sipMonth.compareToIgnoreCase(FEB) == 0) {
        month = Calendar.FEBRUARY;
    } else if (sipMonth.compareToIgnoreCase(MAR) == 0) {
        month = Calendar.MARCH;
    } else if (sipMonth.compareToIgnoreCase(APR) == 0) {
        month = Calendar.APRIL;
    } else if (sipMonth.compareToIgnoreCase(MAY) == 0) {
        month = Calendar.MAY;
    } else if (sipMonth.compareToIgnoreCase(JUN) == 0) {
        month = Calendar.JUNE;
    } else if (sipMonth.compareToIgnoreCase(JUL) == 0) {
        month = Calendar.JULY;
    } else if (sipMonth.compareToIgnoreCase(AUG) == 0) {
        month = Calendar.AUGUST;
    } else if (sipMonth.compareToIgnoreCase(SEP) == 0) {
        month = Calendar.SEPTEMBER;
    } else if (sipMonth.compareToIgnoreCase(OCT) == 0) {
        month = Calendar.OCTOBER;
    } else if (sipMonth.compareToIgnoreCase(NOV) == 0) {
        month = Calendar.NOVEMBER;
    } else if (sipMonth.compareToIgnoreCase(DEC) == 0) {
        month = Calendar.DECEMBER;
    } else {
        throw new IllegalArgumentException("Illegal Month :" + m);
    }
}
 
Example 13
Project: mumu   File: DateUtils.java   View Source Code Vote up 6 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 14
Project: SlotNSlot_Android   File: HttpDateTime.java   View Source Code Vote up 6 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 15
Project: Past-Client   File: MixinGuiMainMenu.java   View Source Code Vote up 5 votes
@Inject(method = "initGui()V", at = @At("RETURN"), locals = LocalCapture.CAPTURE_FAILSOFT)
private void initSplashText(CallbackInfo callbackInfo, Calendar calendar) {
    if (calendar.get(Calendar.MONTH) == Calendar.JUNE && calendar.get(Calendar.DAY_OF_MONTH) == 21)
        this.splashText = "Happy Birthday Gogume1er!";
}
 
Example 16
Project: SharedPermission   File: DateUtil.java   View Source Code Vote up 5 votes
/***
 * Gets the name of the month from the given date.
 *
 * @param date ISO format date
 * @return Returns the name of the month
 */
public static String getMonth(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 = "January";
            break;

        case Calendar.FEBRUARY:
            dayStr = "February";
            break;

        case Calendar.MARCH:
            dayStr = "March";
            break;

        case Calendar.APRIL:
            dayStr = "April";
            break;

        case Calendar.MAY:
            dayStr = "May";
            break;

        case Calendar.JUNE:
            dayStr = "June";
            break;

        case Calendar.JULY:
            dayStr = "July";
            break;

        case Calendar.AUGUST:
            dayStr = "August";
            break;

        case Calendar.SEPTEMBER:
            dayStr = "September";
            break;

        case Calendar.OCTOBER:
            dayStr = "October";
            break;

        case Calendar.NOVEMBER:
            dayStr = "November";
            break;

        case Calendar.DECEMBER:
            dayStr = "December";
            break;
    }

    return dayStr;
}
 
Example 17
Project: SharedPermission   File: DateUtil.java   View Source Code Vote up 5 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 18
Project: LucaHome-AndroidApplication   File: MenuService.java   View Source Code Vote up 5 votes
private LucaMenu calculateDate(
        @NonNull LucaMenu menu,
        int year,
        int month,
        int dayOfMonth,
        int dayOfWeekDifference) {
    dayOfMonth += dayOfWeekDifference;

    switch (month - 1) {
        case Calendar.JANUARY:
        case Calendar.MARCH:
        case Calendar.MAY:
        case Calendar.JULY:
        case Calendar.AUGUST:
        case Calendar.OCTOBER:
            if (dayOfMonth > 31) {
                dayOfMonth -= 31;
                month++;
            }
            break;
        case Calendar.APRIL:
        case Calendar.JUNE:
        case Calendar.SEPTEMBER:
        case Calendar.NOVEMBER:
            if (dayOfMonth > 30) {
                dayOfMonth -= 30;
                month++;
            }
            break;
        case Calendar.FEBRUARY:
            if (year % 4 == 0) {
                if (dayOfMonth > 29) {
                    dayOfMonth -= 29;
                    month++;
                }
            } else {
                if (dayOfMonth > 28) {
                    dayOfMonth -= 28;
                    month++;
                }
            }
            break;
        case Calendar.DECEMBER:
            if (dayOfMonth > 31) {
                dayOfMonth -= 31;
                month = 1;
                year++;
            }
            break;
        default:
            Logger.getInstance().Error(TAG, String.format(Locale.getDefault(), "Invalid month %d!", month));
            return null;
    }

    menu.SetDate(new SerializableDate(year, month, dayOfMonth));

    return menu;
}
 
Example 19
Project: myfaces-trinidad   File: TrinidadDateTimeConverterTest.java   View Source Code Vote up 5 votes
protected void dotestLeniencyOnPattern(
  String primaryPattern,
  String secondaryPatttern
  )
{
  // inputs such as 6/7/2004 is also valid. Avoiding it since - equality
  // of the output is also compared.

  // Each of these inputs ends up causing the MessageFactory to grab the
  // label from the component a different number of times, so the number of
  // iterations to set the component up for is difficult to figure. The
  // numbers after the input string are the number of iterations of
  // getAttribute that we need to set up for.
  String[] validInputs =
    {
      "Jun/4/2004" /* 0 */, "Jun-4-2004" /* 10 */, "Jun.4.2004" /* 8 */,
      "06/4/2004"  /* 4 */, "06-04-2004" /* 12 */, "06.04.2004" /* 2 */,
      "6/4/2004"   /* 4 */, "6-4-2004"   /* 12 */, "6.4.2004"   /* 2 */
    };

  int iterations = (0 + 10 + 8 + 4 + 12 + 2 + 4 + 12 + 2);
  GregorianCalendar cal = new GregorianCalendar(2004, Calendar.JUNE, 4);
  cal.setTimeZone(DEFAULT_TIME_ZONE);
  Date dt = cal.getTime();
  Mock mock = buildMockUIComponent(iterations);
  UIComponent component = (UIComponent) mock.proxy();
  
  for (int i = 0; i < validInputs.length; i++)
  {
    DateTimeConverter
      dtConv = (DateTimeConverter) getDateTimeConverter();
    dtConv.setLocale(Locale.ENGLISH);
    dtConv.setPattern(primaryPattern);
    dtConv.setSecondaryPattern(secondaryPatttern);
    dtConv.setTimeZone(DEFAULT_TIME_ZONE);
    dtConv.setType("INVALID"); // make this type invalid

    Date convDate = (Date) dtConv.getAsObject(facesContext, component,
                                              validInputs[i]);
    assertEquals(convDate, dt);
    mock.verify();
  }
}
 
Example 20
Project: SmartMath   File: MFPDateTime.java   View Source Code Vote up 5 votes
public static DataClass getMonth(LinkedList<DataClass> listParams) throws JFCALCExpErrException {
    if (listParams.size() != 1)   {
        throw new JFCALCExpErrException(ERRORTYPES.ERROR_INCORRECT_NUM_OF_PARAMETER);
    }
    DataClass datumTS = new DataClass();
    datumTS.copyTypeValueDeep(listParams.removeLast());
    datumTS.changeDataType(DATATYPES.DATUM_INTEGER);
    long lTS = datumTS.getDataValue().longValue();
    Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(lTS);
    int nReturn = cal.get(Calendar.MONTH);
    int nMonth = 1;
    switch (nReturn) {
        case (Calendar.JANUARY): {
            nMonth = 1;
            break;
        } case (Calendar.FEBRUARY): {
            nMonth = 2;
            break;
        } case (Calendar.MARCH): {
            nMonth = 3;
            break;
        } case (Calendar.APRIL): {
            nMonth = 4;
            break;
        } case (Calendar.MAY): {
            nMonth = 5;
            break;
        } case (Calendar.JUNE): {
            nMonth = 6;
            break;
        } case (Calendar.JULY): {
            nMonth = 7;
            break;
        } case (Calendar.AUGUST): {
            nMonth = 8;
            break;
        } case (Calendar.SEPTEMBER): {
            nMonth = 9;
            break;
        } case (Calendar.OCTOBER): {
            nMonth = 10;
            break;
        } case (Calendar.NOVEMBER): {
            nMonth = 11;
            break;
        } case (Calendar.DECEMBER): {
            nMonth = 12;
            break;
        }
    }
    return new DataClass(DATATYPES.DATUM_INTEGER, new MFPNumeric(nMonth));
}