Java Day in Month getNumDaysInMonth(String monthID, String yearID)

Here you can find the source of getNumDaysInMonth(String monthID, String yearID)

Description

get Num Days In Month

License

Open Source License

Declaration

public static int getNumDaysInMonth(String monthID, String yearID) 

Method Source Code

//package com.java2s;
/*/*from   w  w  w  . j  a  va2  s  .c om*/
 * Copyright (c) 2013 The Johns Hopkins University/Applied Physics Laboratory
 *                             All rights reserved.
 *
 * This material may be used, modified, or reproduced by or for the U.S.
 * Government pursuant to the rights granted under the clauses at
 * DFARS 252.227-7013/7014 or FAR 52.227-14.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * NO WARRANTY.   THIS MATERIAL IS PROVIDED "AS IS."  JHU/APL DISCLAIMS ALL
 * WARRANTIES IN THE MATERIAL, WHETHER EXPRESS OR IMPLIED, INCLUDING (BUT NOT
 * LIMITED TO) ANY AND ALL IMPLIED WARRANTIES OF PERFORMANCE,
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT OF
 * INTELLECTUAL PROPERTY RIGHTS. ANY USER OF THE MATERIAL ASSUMES THE ENTIRE
 * RISK AND LIABILITY FOR USING THE MATERIAL.  IN NO EVENT SHALL JHU/APL BE
 * LIABLE TO ANY USER OF THE MATERIAL FOR ANY ACTUAL, INDIRECT,
 * CONSEQUENTIAL, SPECIAL OR OTHER DAMAGES ARISING FROM THE USE OF, OR
 * INABILITY TO USE, THE MATERIAL, INCLUDING, BUT NOT LIMITED TO, ANY DAMAGES
 * FOR LOST PROFITS.
 */

public class Main {
    public static int getNumDaysInMonth(String monthID, String yearID) {
        int returnVal = 31;
        if (monthID != null) {
            int integerMonthID = (new Integer(monthID)).intValue();
            if ((integerMonthID == 3) || (integerMonthID == 5) || (integerMonthID == 8) || (integerMonthID == 10)) {
                returnVal = 30;
            } else if (integerMonthID == 1) {
                returnVal = 28;
                if (yearID != null) {
                    double integerYearID = (new Integer(yearID)).intValue();
                    System.out.println(
                            "integerYearID=" + integerYearID + "; " + "integerYearID/4=" + (integerYearID / 4)
                                    + "; " + "Math.floor(integerYearID/4)=" + (Math.floor(integerYearID / 4)));
                    if ((integerYearID / 4) == (Math.floor(integerYearID / 4))) {
                        System.out.println("Leap year");
                        returnVal = 29;
                    } else {
                        System.out.println("Not leap year");
                    }
                }
            }
        }
        return returnVal;
    }
}

Related

  1. getMonthDayString(long l, boolean timezone, boolean formated)
  2. getMonthlyCronExpression(int minutes, int hours, int dayOfMonth)
  3. getMonthOfDayMark(int day)
  4. getNumberOfDaysInMonth(Integer year, Integer month)
  5. getNumberOfDaysInMonthes(int theyear)
  6. getPreMonthDayStr(String curday)
  7. getStartMonthDayOfDate(String yyyyMM)
  8. is31DaysMonth(int month)
  9. isDayMonth(String types)