Here you can find the source of monthOfYear(Date referenceDate, int month, TimeZone timeZone)
Parameter | Description |
---|---|
referenceDate | The whole date. |
month | The month to calculate the start of. 1 is January, 12 is December. |
public static Calendar monthOfYear(Date referenceDate, int month, TimeZone timeZone)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import java.util.Date; import java.util.TimeZone; public class Main { /**/*from ww w .j a va2 s. c o m*/ * Utility function to get the start of the month as a Calendar. * * @param referenceDate The whole date. * @param month The month to calculate the start of. 1 is January, * 12 is December. * * @return The start of the month. */ public static Calendar monthOfYear(Date referenceDate, int month, TimeZone timeZone) { Calendar c1 = Calendar.getInstance(timeZone); c1.setTime(referenceDate); Calendar c2 = Calendar.getInstance(timeZone); c2.clear(); // Adjust for Java 0 based months. c2.set(c1.get(Calendar.YEAR), month - 1, 1); return c2; } }