Here you can find the source of getBeginningOfYear()
public static Date getBeginningOfYear()
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { /**/* www . j av a 2s. com*/ * @return the first date of the current year (i.e. 01/01/XXXX @ 00:00:00) */ public static Date getBeginningOfYear() { return getBeginningOfYear(null); } /** * @param date a date (if null, 'now' is assumed) * @return the first date of the year of <code>code</code> (i.e. 01/01/date.year @ 00:00:00) */ public static Date getBeginningOfYear(Date date) { Calendar c = Calendar.getInstance(); // if date is null, "c" is the current date if (date != null) c.setTime(date); c.set(Calendar.DAY_OF_MONTH, 1); c.set(Calendar.MONTH, 0); c.set(Calendar.HOUR_OF_DAY, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); return c.getTime(); } }