Java Date to Quarter getQuarterlyKey(Date d)

Here you can find the source of getQuarterlyKey(Date d)

Description

get Quarterly Key

License

Apache License

Declaration

public static String getQuarterlyKey(Date d) 

Method Source Code


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

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

public class Main {
    public static String getQuarterlyKey(Date d) {
        Calendar c = Calendar.getInstance();
        c.setTime(d);/*from  w  ww . j a  v a2  s.  co m*/

        int month = c.get(Calendar.MONTH);

        int q = (((month + 1) / 3) + 3) % 4 + 1;

        int fy = c.get(Calendar.YEAR);
        if (month >= 2) {
            fy++;
        }

        return "FY" + fy + "_Q" + q;
    }
}

Related

  1. getQuarter(Date date)
  2. getQuarter(Date date)
  3. getQuarter(Date date)
  4. getQuarter(Date date)
  5. getQuarterBounds(final Date date)
  6. getQuarterNum(Date date)
  7. getQuarterNum(Date dt)
  8. getQuarterOfDay(Date day)
  9. getQuarterStart(Date date)