Here you can find the source of getQuarterNum(Date date)
private static int getQuarterNum(Date date)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { private static int getQuarterNum(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date);/* w ww . jav a 2s.c o m*/ int currentMonth = cal.get(Calendar.MONTH) + 1; switch (currentMonth) { case 1: case 2: case 3: return 1; case 4: case 5: case 6: return 2; case 7: case 8: case 9: return 3; case 10: case 11: case 12: return 4; } return 0; } }