Java Date to Year getYearStart(Date date)

Here you can find the source of getYearStart(Date date)

Description

get Year Start

License

Open Source License

Declaration

public static Date getYearStart(Date date) 

Method Source Code

//package com.java2s;

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

public class Main {
    public static Date getYearStart(Date date) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);/*from  w ww  .j av a  2s .  c o m*/
        cal.set(Calendar.MONTH, Calendar.JANUARY);
        cal.set(Calendar.DAY_OF_MONTH, 1);
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);

        return cal.getTime();
    }
}

Related

  1. getYearNumber(Date date)
  2. getYearOfDate(Date date)
  3. getYearOfThisYear(Date currentdate)
  4. getYearOnlyDate(String year)
  5. getYears(java.util.Date date0, java.util.Date date1)
  6. getYearString(Date date)