Here you can find the source of startOfYear(Date referenceDate, TimeZone timeZone)
Parameter | Description |
---|---|
referenceDate | The given date. |
public static Calendar startOfYear(Date referenceDate, 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 { /**//ww w. j a v a2 s . c o m * Calculate the date at the start of the year for the given date. * * @param referenceDate The given date. * @return The calendar at the start of the year. */ public static Calendar startOfYear(Date referenceDate, TimeZone timeZone) { Calendar c1 = Calendar.getInstance(timeZone); c1.setTime(referenceDate); Calendar c2 = Calendar.getInstance(timeZone); c2.clear(); c2.set(c1.get(Calendar.YEAR), 0, 1); return c2; } }