Here you can find the source of getFirstDayOfYear(int year)
public static Date getFirstDayOfYear(int year)
//package com.java2s; //License from project: LGPL import java.util.Calendar; import java.util.Date; public class Main { public static Date getFirstDayOfYear(int year) { return getFirstDayOfQuarter(year, 1); }//from w w w. j av a2 s . c o m public static Date getFirstDayOfQuarter(int year, int quarter) { int month = 0; if (quarter > 4) { return null; } else { month = (quarter - 1) * 3 + 1; } return getFirstDayOfMonth(year, month); } public static Date getFirstDayOfMonth(int year, int month) { Calendar c = Calendar.getInstance(); c.set(Calendar.YEAR, year); c.set(Calendar.MONTH, month - 1); c.set(Calendar.DAY_OF_MONTH, c.getActualMinimum(Calendar.DAY_OF_MONTH)); c.set(Calendar.HOUR, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); return c.getTime(); } }