Java Month of Year getCalforMonth(String month, String year)

Here you can find the source of getCalforMonth(String month, String year)

Description

get Calfor Month

License

Open Source License

Declaration

public static Calendar getCalforMonth(String month, String year) 

Method Source Code

//package com.java2s;
/** Exhibit A - UIRF Open-source Based Public Software License.
* 
* The contents of this file are subject to the UIRF Open-source Based
* Public Software License(the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* openelis.uhl.uiowa.edu/* w w  w  . j  a  va2s.  co m*/
* 
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
* 
* The Original Code is OpenELIS code.
* 
* The Initial Developer of the Original Code is The University of Iowa.
* Portions created by The University of Iowa are Copyright 2006-2008. All
* Rights Reserved.
* 
* Contributor(s): ______________________________________.
* 
* Alternatively, the contents of this file marked
* "Separately-Licensed" may be used under the terms of a UIRF Software
* license ("UIRF Software License"), in which case the provisions of a
* UIRF Software License are applicable instead of those above. 
*/

import java.util.Calendar;

public class Main {
    public static Calendar getCalforMonth(String month, String year) {
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.MONTH, Integer.parseInt(month));
        cal.set(Calendar.YEAR, Integer.parseInt(year));
        cal.set(Calendar.DATE, 1);
        if (cal.get(Calendar.DAY_OF_WEEK) > 1)
            cal.add(Calendar.DATE, -cal.get(Calendar.DAY_OF_WEEK));
        else
            cal.add(Calendar.DATE, -8);
        return cal;
    }

    public static Calendar getCalforMonth(int month, int year) {
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.MONTH, month);
        cal.set(Calendar.YEAR, year);
        cal.set(Calendar.DATE, 1);
        if (cal.get(Calendar.DAY_OF_WEEK) > 1)
            cal.add(Calendar.DATE, -cal.get(Calendar.DAY_OF_WEEK));
        else
            cal.add(Calendar.DATE, -8);
        return cal;
    }
}

Related

  1. daysInMonth(int month, int year)
  2. daysInMonth(int year, int month)
  3. daysInMonth(int year, int month)
  4. get_NextSunday_YearMonthDay_integerArray()
  5. getActualMonthBefore(int year, int month, int i)
  6. getDaysByYearMonth(int year, int month)
  7. getDefaultHolidays(int year, int month)
  8. getEndOfMonth(String year, String month)
  9. getFirstMonthOfThisYear()