Here you can find the source of getQuarter(Date date)
public static int getQuarter(Date date)
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { public static int getQuarter(Date date) { if (date == null) { return 0; }/* ww w . ja v a2s . c o m*/ Calendar objCalendar = Calendar.getInstance(); objCalendar.setTime(date); int iMonth = objCalendar.get(Calendar.MONTH) + 1; if ((iMonth >= 1) && (iMonth <= 3)) { return 1; } else if ((iMonth >= 4) && (iMonth <= 6)) { return 2; } else if ((iMonth >= 7) && (iMonth <= 9)) { return 3; } else { return 4; } } }