Java Day in Month getFirstDayOfMonth(int year, int month)

Here you can find the source of getFirstDayOfMonth(int year, int month)

Description

get first date of given month and year

License

Apache License

Parameter

Parameter Description
year a parameter
month a parameter

Declaration

public static String getFirstDayOfMonth(int year, int month) 

Method Source Code

//package com.java2s;
/**//from w  ww.  j a  va  2 s  . c o m
 *  Copyright (c) 2012-2014 http://www.eryansky.com
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 */

public class Main {
    /**
     * get first date of given month and year
     *
     * @param year
     * @param month
     * @return
     */
    public static String getFirstDayOfMonth(int year, int month) {
        String monthStr = month < 10 ? "0" + month : String.valueOf(month);
        return year + "-" + monthStr + "-" + "01";
    }
}

Related

  1. getDaysInMonth(int month, int year)
  2. getDaysInMonth(int monthNum)
  3. getDaysInMonth(int year, int month)
  4. getDaysInMonths()
  5. getDaysOfMonth(Date startdate, Date enddate, String month)
  6. getFirstdayOfMonth(String year, String month)
  7. getLastDayInMonth(int month, int year)
  8. getLastDayOfMonth(int year, int month)
  9. getLastDayOfMonth(String monthInitials)