Java Date to Quarter getQuarter(Date date)

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

Description

get Quarter

License

Apache License

Parameter

Parameter Description
date a parameter

Return

int

Declaration

public static int getQuarter(Date date) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

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

public class Main {

    public static int getQuarter(Date date) {
        Calendar cld = Calendar.getInstance();
        cld.setTime(date);//  ww w  .j ava  2  s .co m
        Double dd = new Double(Math.floor(cld.get(Calendar.MONTH) / 3));
        return dd.intValue() + 1;
    }
}

Related

  1. getQuarter(Date date)
  2. getQuarter(Date date)
  3. getQuarter(Date date)
  4. getQuarterBounds(final Date date)