How do I discover the Quarter of a given Date?

前端 未结 14 1199
小鲜肉
小鲜肉 2020-12-24 05:37

Given a java.util.Date object how do I go about finding what Quarter it\'s in?

Assuming Q1 = Jan Feb Mar, Q2 = Apr, May, Jun, etc.

14条回答
  •  余生分开走
    2020-12-24 06:19

    For Me, I Used this method for string representation:

    int quarter = (Calendar.getInstance().get(Calendar.MONTH) / 3); // 0 to 3
    String[] mQuarterKey = {"qt1", "qt2", "qt3", "qt4"};
    String strQuarter = mQuarterKey[quarter];
    

提交回复
热议问题