Solved

Function to calculate fiscal year from date passed in java

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB6 Compile Compatibility Issue 4 87
I need an assist with a programming logic math question. 5 55
Base1 Encode/Decode 3 67
Advice on Xojo as a development tool over VB. 4 31
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 …
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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…

930 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

18 Experts available now in Live!

Get 1:1 Help Now