Java Date to Year getYearBegin(final Date date)

Here you can find the source of getYearBegin(final Date date)

Description

get Year Begin

License

Open Source License

Declaration

public static Date getYearBegin(final Date date) 

Method Source Code

//package com.java2s;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class Main {
    public static Date getYearBegin(final Date date) {
        if (date == null) {
            return null;
        }//  w ww  .  ja v a  2  s . c  o m

        Calendar cal = GregorianCalendar.getInstance();
        cal.setTime(date);
        cal.set(Calendar.MONTH, 0);
        cal.set(Calendar.DATE, 1);

        return cal.getTime();
    }
}

Related

  1. getYear(java.util.Date date)
  2. getYear(java.util.Date today)
  3. getYear(String sdate)
  4. getYear(String strDate)
  5. getYearAsInt(Date aDate)
  6. getYearBetweenTwoDate(Date fdate, Date tdate)
  7. getYearFromDate(Date date)
  8. getYearFromDate(Date date)
  9. getYearMonth(Date date)