Java Day Of Year getFirstDayOfYear(int year)

Here you can find the source of getFirstDayOfYear(int year)

Description

get First Day Of Year

License

LGPL

Declaration

public static Date getFirstDayOfYear(int year) 

Method Source Code

//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();
    }
}

Related

  1. getDaysInYear(int year)
  2. getDaysInYear(int year)
  3. getDaysOfYear(int year)
  4. getEndTimeOfYear(int year)
  5. getFirstDayOfTheYear(int year)
  6. getLastYearOfToday()
  7. getMaxDayByYearMonth(String ym)
  8. getMaxDayOfYearMonth(String date)
  9. getMaxWeekNumOfYear(int year)