Solved

Function to calculate fiscal year from date passed in java

Posted on 2013-01-09
3
3,193 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
  • 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

RIA (Rich Internet Application) tools are interactive internet applications which have many of the characteristics of desktop applications. The RIA tools typically deliver output either by the way of a site-specific browser or via browser plug-in. T…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now