Solved

Function to calculate fiscal year from date passed in java

Posted on 2013-01-09
3
3,766 Views
Last Modified: 2013-11-13
Hi,

I need a function which calculates the fiscal year and returns true or false based on the date passed. Our system financial fiscal year is Apr 01 - Mar 31.

For ex. Current year is 2013. If the passed date is 2012-12-12 (YYYY-MM-DD) then the function should return true. If the passed date is 2012-01-12 (YYYY-MM-DD) then the function should return false.

Thanks in advance.
0
Comment
Question by:manohar27
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Author Comment

by:manohar27
ID: 38759975
test
0
 

Author Comment

by:manohar27
ID: 38760476
Bit Correction here:

For ex. Current year is 2013. If the passed date is 2012-12-12 (YYYY-MM-DD) then the function should return false. If the passed date is 2011-12-12 (YYYY-MM-DD) then the function should return true.
0
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 38762757
public static Boolean fiscal(String date){
     Calendar now = Calendar.getInstance();
     int year=now.get(Calendar.YEAR) - (now.get(Calendar.MONTH) < 4?1:0);
     String start=year + "-04-01";
     String end=(year+1) + "-03-31";
     return !(date.compareTo(start)>=0  && date.compareTo(end) <= 0);
    }
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is about my first experience with programming Arduino.
In this post we will learn different types of Android Layout and some basics of an Android App.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Progress

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question