Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Java
Expertise: Intermediate
Oct 5, 2004



Application Security Testing: An Integral Part of DevOps

Get the End Date of a Financial Quarter

Often, in financial applications, the quarter end date is very important for financial calculations. The following function gets the end date of a Financial Quarter that is relative to the date value passed. For example, suppose you are passing "12-Apr-2004" as the Date. The corresponding quarter end date returned will be "30-Jun-2004."

public static Date getFinancialQuarterEndDate(Date date) {
	Calendar calendar = new GregorianCalendar();
	int factor = 0;
	int month = calendar.get(Calendar.MONTH);
	if (month == Calendar.JANUARY
		|| month == Calendar.APRIL
		|| month == Calendar.JULY
		|| month == Calendar.OCTOBER) {
		factor = 2;
	} else if (
		month == Calendar.FEBRUARY
		|| month == Calendar.MAY
		|| month == Calendar.AUGUST
		|| month == Calendar.NOVEMBER) {
		factor = 1;
		} else {
			factor = 0;

	calendar.add(Calendar.MONTH, factor);
	calendar.set(Calendar.DATE, calendar.getActualMaximum(Calendar.DATE));
	return calendar.getTime();
Vijayanandraj Amaladoss
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date