Java Month getCurrDateByMonth(String date)

Here you can find the source of getCurrDateByMonth(String date)

Description

get Curr Date By Month

License

Open Source License

Declaration

public static String getCurrDateByMonth(String date) 

Method Source Code

//package com.java2s;

public class Main {
    public static String getCurrDateByMonth(String date) {
        int day = days(Integer.parseInt(date.substring(0, 4)), Integer.parseInt(date.substring(5, 7)));
        return date + "-" + day;
    }/*from  w  ww.  j  a  v  a  2 s.c o  m*/

    public static int days(int year, int month) {
        int total = 30;
        switch (month) {
        case 1:
        case 3:
        case 5:
        case 7:
        case 8:
        case 10:
        case 12:
            total = 31;
            break;
        case 2:
            if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
                total = 29;
            else
                total = 28;
            break;
        default:
            break;
        }
        return total;
    }
}

Related

  1. findMonth(String strMonth)
  2. fixMonth(int month)
  3. fixMonth(String m)
  4. getAllowMonth(String startdate, int count)
  5. getAssignMonth(String date)
  6. getEnligthMonth(String en)
  7. getEnMonth(String month)
  8. getFirstMonthByQuarter(int month)
  9. getFirstMonthOfQuarter(String quarter)