Java Date to Quarter getQuarterNum(Date dt)

Here you can find the source of getQuarterNum(Date dt)

Description

get Quarter Num

License

Open Source License

Declaration

public static int getQuarterNum(Date dt) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    public static int getQuarterNum(Date dt) {
        if (dt == null)
            return 0;
        GregorianCalendar gc = new GregorianCalendar();
        gc.setTime(dt);/*from   w w w  .  jav a 2 s.  c  o  m*/

        int thisMonth = gc.get(Calendar.MONTH);

        return thisMonth / 4 + 1;
    }
}

Related

  1. getQuarter(Date date)
  2. getQuarter(Date date)
  3. getQuarterBounds(final Date date)
  4. getQuarterlyKey(Date d)
  5. getQuarterNum(Date date)
  6. getQuarterOfDay(Date day)
  7. getQuarterStart(Date date)
  8. getQuarterYear(Date dateParam)
  9. getQuaterStart(Date date)