Java Code Examples for java.util.Calendar.APRIL

The following are Jave code examples for showing how to use APRIL 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: BetterThanLlamas   File: LayerFancyLlama.java   View Source Code Vote up 7 votes
public LayerFancyLlama(RenderLlama renderer)
{
    this.renderer = renderer;
    this.rand = new Random();
    this.modelFancy = new ModelFancy();

    Calendar calendar = Calendar.getInstance();
    calendar.setTimeInMillis(System.currentTimeMillis());

    isAFDay = calendar.get(Calendar.MONTH) == Calendar.APRIL && calendar.get(Calendar.DAY_OF_MONTH) == 1;
    if(isAFDay)
    {
        modelRabbit = new ModelRabbit();
        modelRabbit.isChild = false;
        rabbitInstance = new EntityRabbit(null);
        if(renderer.mainModel instanceof ModelLlama)
        {
            ((ModelLlama)renderer.mainModel).head = new ModelRenderer(renderer.mainModel, 33, 4);
            ((ModelLlama)renderer.mainModel).head.addBox(-4.0F, -9.0F, -6.0F, 8, 11, 6, 0);
            ((ModelLlama)renderer.mainModel).head.setRotationPoint(0.0F, 7.0F, -6.0F);
        }
    }
}
 
Example 3
Project: CalendarCheck   File: CalendarUtils.java   View Source Code Vote up 7 votes
/**
 * @param month 从0开始
 * @param year  年份
 * @return days
 */
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)) ? 29 : 28;
        default:
            throw new IllegalArgumentException("Invalid Month");
    }
}
 
Example 4
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 5
Project: oscm   File: BillingServiceBeanSteppedPriceIT.java   View Source Code Vote up 7 votes
private void testBillingWithSteppedPricesForParameters(int paramValue,
        BigDecimal expectedOverAllCosts,
        BigDecimal expectedSteppedPricesAmount,
        final BigDecimal[] stepAmountArray,
        final BigDecimal[] stepEventCountArray, long paramModificationTime)
        throws Exception {

    final int testMonth = Calendar.APRIL;
    final int testDay = 1;
    final int testYear = 2010;
    final long billingTime = getTimeInMillisForBilling(testYear, testMonth,
            testDay);

    long subscriptionCreationTime = getTimeInMillisForBilling(testYear,
            testMonth - 2, testDay);
    long subscriptionActivationTime = subscriptionCreationTime;

    testBillingWithSteppedPricesForParameters(paramValue,
            expectedOverAllCosts, expectedSteppedPricesAmount,
            stepAmountArray, stepEventCountArray, 0, billingTime,
            subscriptionCreationTime, subscriptionActivationTime,
            paramModificationTime);

}
 
Example 6
Project: GitHub   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 7
Project: minu-poska-android   File: DataUtils.java   View Source Code Vote up 6 votes
public static String getLanguage(final Context context) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    String lang = sp.getString(LANGUAGE_SELECTION, "et");

    Calendar cal = Calendar.getInstance();
    //noinspection WrongConstant
    if (cal.get(Calendar.MONTH) == Calendar.APRIL && cal.get(Calendar.DAY_OF_MONTH) == 1) {
        Log.d(TAG, "Activating April Fools Joke for app language!");
        // APRIL FOOLS!
        lang = "wo";
        setLanguage(context, lang);
    }
    return lang;
}
 
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: openjdk-jdk10   File: Bug4395196.java   View Source Code Vote up 6 votes
public static void main(String[] arg)
        {
                int result = 0;
                Locale loc = new Locale("ko","KR");
                Date now = new Date(108, Calendar.APRIL, 9);

                DateFormat df =
                   DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.SHORT,loc);
                SimpleDateFormat sdf = new SimpleDateFormat("",loc);
                sdf.applyPattern("yyyy. M. d a h:mm");
                if( !sdf.format(now).equals(df.format(now))){
                 result++;
                 System.out.println("error at " + sdf.format(now));
                 }
                df =  DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.MEDIUM,loc);
                sdf.applyPattern("yyyy'\ub144' M'\uc6d4' d'\uc77c' '('EE')' a h:mm:ss");
                if( !sdf.format(now).equals(df.format(now))){
                 result++;
                 System.out.println("error at " + sdf.format(now));
                 }
                df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG,loc);
                sdf.applyPattern("yyyy. M. d a h'\uc2dc' mm'\ubd84' ss'\ucd08'");
                if( !sdf.format(now).equals(df.format(now))){
                 result++;
                 System.out.println("error at " + sdf.format(now));
                 }
                df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.FULL,loc);
                sdf.applyPattern("yy. M. d a h'\uc2dc' mm'\ubd84' ss'\ucd08' z");
                if( !sdf.format(now).equals(df.format(now))){
                 result++;
                 System.out.println("error at " + sdf.format(now));
                 }

           if(result > 0) throw new RuntimeException();
}
 
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: 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 12
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 13
Project: oscm   File: BillingServiceBeanSteppedPriceIT.java   View Source Code Vote up 6 votes
/**
 * Test for price model, events, priced parameter with stepped prices.
 * 
 * @throws Exception
 */
@Test
public void testBillingWithSteppedPricesForAll() throws Exception {

    final int testMonth = Calendar.APRIL;
    final int testDay = 1;
    final int testYear = 2010;
    final long billingTime = getTimeInMillisForBilling(testYear, testMonth,
            testDay);

    long subscriptionCreationTime = getTimeInMillisForBilling(testYear,
            testMonth - 2, testDay);
    long subscriptionActivationTime = subscriptionCreationTime;

    BigDecimal[] priceArray = { BD100, BD90, BD80 };
    long[] freeAmountArray = { 0, 10, 20 };
    BigDecimal[] additionalPriceArray = { BigDecimal.ZERO, BD1000,
            BigDecimal.valueOf(1900) };

    initData(billingTime, subscriptionCreationTime,
            subscriptionActivationTime, limitArray, priceArray,
            freeAmountArray, additionalPriceArray);

    runTX(new Callable<Void>() {
        @Override
        public Void call() throws Exception {
            billingService.startBillingRun(billingTime);
            return null;
        }
    });
    Document doc = getBillingDocument();

    String netCosts = XMLConverter.getNodeTextContentByXPath(doc,
            "/BillingDetails/OverallCosts/@netAmount");
    checkEquals("BugWrong net costs found", "230064.00", netCosts);
    xmlValidator.validateBillingResultXML();
}
 
Example 14
Project: minu-poska-android   File: DataUtils.java   View Source Code Vote up 6 votes
public static void markEulaAccepted(final Context context) {
    Log.d(TAG, "Marking EULA accepted.");
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    Calendar cal = Calendar.getInstance();
    //noinspection WrongConstant
    if (cal.get(Calendar.MONTH) == Calendar.APRIL && cal.get(Calendar.DAY_OF_MONTH) == 1) {
        Log.d(TAG, "Accepting April Fools Joke for EULA!");
        // APRIL FOOLS!
        sp.edit().putBoolean(EULA_ACCEPTED + ".april" + cal.get(Calendar.YEAR), true).apply();
    }
    sp.edit().putBoolean(EULA_ACCEPTED, true).apply();
}
 
Example 15
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 16
Project: minu-poska-android   File: DataUtils.java   View Source Code Vote up 6 votes
public static boolean isEulaAccepted(final Context context) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    Calendar cal = Calendar.getInstance();
    //noinspection WrongConstant
    if (cal.get(Calendar.MONTH) == Calendar.APRIL && cal.get(Calendar.DAY_OF_MONTH) == 1) {
        Log.d(TAG, "Activating April Fools Joke for EULA!");
        // APRIL FOOLS!
        return sp.getBoolean(EULA_ACCEPTED + ".april" + cal.get(Calendar.YEAR), false);
    }

    return sp.getBoolean(EULA_ACCEPTED, false);
}
 
Example 17
Project: oscm   File: BillingServiceRolePricesIT.java   View Source Code Vote up 6 votes
/**
 * Billing test for price model with stepped price.
 * 
 * @throws Exception
 */
private void testBillingWithRolesForUserAssignment(int numUser,
        BigDecimal expectedPrice) throws Exception {

    final int testMonth = Calendar.APRIL;
    final int testDay = 1;
    final int testYear = 2010;
    final long billingTime = getTimeInMillisForBilling(testYear, testMonth,
            testDay);

    long subscriptionCreationTime = getTimeInMillisForBilling(testYear,
            testMonth - 2, testDay);
    long subscriptionActivationTime = getTimeInMillisForBilling(testYear,
            testMonth - 2, testDay);

    int userNumber = numUser;

    initDataPriceModel(userNumber, subscriptionCreationTime,
            subscriptionActivationTime);

    runTX(new Callable<Void>() {
        @Override
        public Void call() throws Exception {
            billingService.startBillingRun(billingTime);
            return null;
        }
    });
    Document doc = getBillingDocument();

    String costs = XMLConverter.getNodeTextContentByXPath(doc,
            "/BillingDetails/OverallCosts/@grossAmount");
    checkEquals(expectedPrice.toPlainString(), costs);
}
 
Example 18
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));
}
 
Example 19
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 20
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;
}