I am using java 1.7, How to find the quarter to which a particular date belong for a Fiscal year, which can start from 1st of any month (JAN-DEC) and also need the start date
Use a calendar:
Calendar cal = Calendar.getInstance();
cal.setTime(myDate);
Quarter:
int q = cal.get(Calendar.MONTH)%3;
System.out.println("Quarter: Q" + (q + 1));
Begining of quarter:
cal.set(Calendar.MONTH, 3*q);
cal.set(Calendar.DAY_OF_MONTH, 1);
Date start = cal.getTime();
System.out.println("Start: " + start);
End of quarter:
cal.add(Calendar.MONTH, 3);
cal.add(Calendar.DATE, -1);
Date end = cal.getTime();
System.out.println("End: " + end);