Solved

Function to calculate fiscal year from date passed in java

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
mapShare challenge 13 103
WMI, model #, retrieving information 10 137
Windows and other UI names - The Proper names for the Various elements! 1 80
Beginner to Unreal Engine 4 5 79
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
A short article about a problem I had getting the GPS LocationListener working.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
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…

806 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