从当前日期获取当前财政年度(YYYY-YYYY)

时间:2013-09-04 14:32:10

标签: java

我试图以更有效的方式在当前日期的基础上找出当前财政年度(财政年度 - 3月至4月)。这是我到目前为止所写的内容

public static void main(String[] args) {

        int year = getYearFromDate(new Date());
        System.out.println("Financial Year : " + year + "-" + (year+1));
        System.out.println("Financial month : " + getMonthFromDate(new Date()));
    }

    private static int getMonthFromDate(Date date) {
         int result = -1;
            if (date != null) {
                Calendar cal = Calendar.getInstance();
                cal.setTime(date);
                result = cal.get(Calendar.MONTH)+1;
            }
            return result;
    }

    public static int getYearFromDate(Date date) {
        int result = -1;
        if (date != null) {
            Calendar cal = Calendar.getInstance();
            cal.setTime(date);
            result = cal.get(Calendar.YEAR);
        }
        return result;
    }

因此,如果当前月份小于或等于3(3月)且年份为2013年,则FY应为= 2012-2013,如果月份为6(6月)且年份为2013年,则FY应为= 2013- 2014年

我如何实现它?

10 个答案:

答案 0 :(得分:7)

我怀疑所需的价值之一是财政月。会计月份是会计年度内的月份。例如,如果会计年度从3月份开始,则3月份是会计年度的0个月。 2月是本财政年度的11个月。

以下是一些测试结果:

Current Date : Wed Sep 04 14:23:17 EDT 2013
Fiscal Years : 2013-2014
Fiscal Month : 6

Current Date : Fri Feb 01 00:00:00 EST 2013
Fiscal Years : 2012-2013
Fiscal Month : 11

Current Date : Wed Jul 25 00:00:00 EDT 2012
Fiscal Years : 2012-2013
Fiscal Month : 4

借用Kevin Bowersox's answer,这是一个FiscalDate类,它给出会计年度和会计月度,以及日历年和日历月。两个月的值均为零。

import java.util.Calendar;
import java.util.Date;

public class FiscalDate {

    private static final int    FIRST_FISCAL_MONTH  = Calendar.MARCH;

    private Calendar            calendarDate;

    public FiscalDate(Calendar calendarDate) {
        this.calendarDate = calendarDate;
    }

    public FiscalDate(Date date) {
        this.calendarDate = Calendar.getInstance();
        this.calendarDate.setTime(date);
    }

    public int getFiscalMonth() {
        int month = calendarDate.get(Calendar.MONTH);
        int result = ((month - FIRST_FISCAL_MONTH - 1) % 12) + 1;
        if (result < 0) {
            result += 12;
        }
        return result;
    }

    public int getFiscalYear() {
        int month = calendarDate.get(Calendar.MONTH);
        int year = calendarDate.get(Calendar.YEAR);
        return (month >= FIRST_FISCAL_MONTH) ? year : year - 1;
    }

    public int getCalendarMonth() {
        return calendarDate.get(Calendar.MONTH);
    }

    public int getCalendarYear() {
        return calendarDate.get(Calendar.YEAR);
    }

    public static void main(String[] args) {
        displayFinancialDate(Calendar.getInstance());
        displayFinancialDate(setDate(2013, 1, 1));
        displayFinancialDate(setDate(2012, 6, 25));
    }

    private static Calendar setDate(int year, int month, int day) {
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.YEAR, year);
        calendar.set(Calendar.MONTH, month);
        calendar.set(Calendar.DAY_OF_MONTH, day);
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);

        return calendar;
    }

    private static void displayFinancialDate(Calendar calendar) {
        FiscalDate fiscalDate = new FiscalDate(calendar);
        int year = fiscalDate.getFiscalYear();
        System.out.println("Current Date : " + calendar.getTime().toString());
        System.out.println("Fiscal Years : " + year + "-" + (year + 1));
        System.out.println("Fiscal Month : " + fiscalDate.getFiscalMonth());
        System.out.println(" ");
    }

}

答案 1 :(得分:4)

public static void main(String[] args) {

    int year = Calendar.getInstance().get(Calendar.YEAR);

    int month = Calendar.getInstance().get(Calendar.MONTH) + 1;
    System.out.println("Financial month : " + month);
    if (month < 3) {
        System.out.println("Financial Year : " + (year - 1) + "-" + year);
    } else {
        System.out.println("Financial Year : " + year + "-" + (year + 1));
    }
}

只需删除额外功能即可。

答案 2 :(得分:3)

我想知道你是否真的试图自己解决它。它是如此明显和直接

psuedo代码:

if ( monthOf(currentDate) >= MARCH) then
  FY =  yearOf(currentDate) + "-" + (yearOf(currentDate) +1);
else 
  FY = (yearOf(currentDate) - 1) + "-" + yearOf(currentDate);

答案 3 :(得分:2)

类似的东西:

Date d = new Date();
int y = d.getMonth() < 3 ? d.getYear() - 1 : d.getYear();

System.out.println("Financial Year : " + y + "-" + (y + 1));
System.out.println("Financial month : " + d.getMonth());

答案 4 :(得分:2)

FiscalDate创建一个对象可能是有益的,因此您可以在整个应用程序中重用它。我会像其他人所建议的那样避免使用getMonth()getYear()等弃用的方法。

import java.util.Calendar;
import java.util.Date;


public class FiscalDate {

    private Date actual;
    private int month;
    private int year;

    public FiscalDate(Date date){
        this.actual = date;
        this.init();
    }

    private void init(){
        Calendar cal = Calendar.getInstance();
        cal.setTime(this.actual);
        this.month = cal.get(Calendar.MONTH);
        int advance = (this.month <= 3) ? -1:0;
        this.year = cal.get(Calendar.YEAR) + advance;
    }

    public Date getActual() {
        return actual;
    }

    public void setActual(Date actual) {
        this.actual = actual;
    }

    public int getMonth() {
        return month;
    }

    public void setMonth(int month) {
        this.month = month;
    }

    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }

    public static void main(String[] args) {
        FiscalDate fDate = new FiscalDate(new Date());
        System.out.println(fDate.getYear());
    }
}

答案 5 :(得分:1)

 int CurrentYear = Calendar.getInstance().get(Calendar.YEAR);
    int CurrentMonth = (Calendar.getInstance().get(Calendar.MONTH)+1);
    String financiyalYearFrom="";
    String financiyalYearTo="";
    if(CurrentMonth<4)
    {
        financiyalYearFrom="01-04-"+(CurrentYear-1);
        financiyalYearTo="31-03-"+(CurrentYear);
    }
    else
    {
        financiyalYearFrom="01-04-"+(CurrentYear);
        financiyalYearTo="31-03-"+(CurrentYear+1);
    }

答案 6 :(得分:1)

Javascript

    let FY = document.getElementById("fYear");
    FY.innerHTML = new Date().getMonth() <= 9 ? "Fiscal Year "+new Date().getFullYear() : "Fiscal Year "+new Date().getFullYear() +1;

答案 7 :(得分:0)

devServer: {
    contentBase: publicPath,
    compress: true,
    hot: true,
    historyApiFallback: true,
    port: 8080
}

答案 8 :(得分:0)

对于那些正在寻找JavaScript解决方案的人来说,这里使用的是MomentJS库。

let financialYear;
let today = moment();
if(today.month() >= 3){
    financialYear = today.format('YYYY') + '-' + today.add(1, 'years').format('YYYY')
}
else{
    financialYear = today.subtract(1, 'years').format('YYYY') + '-' + today.add(1, 'years').format('YYYY')
}
console.log(financialYear)

https://codepen.io/connect_dips/pen/QWWdwed

答案 9 :(得分:0)

此代码允许您使用给定的假设来设置周年纪念日并在不同的构造函数上设置会计年度。

public class FiscalYear {

    public String fyAnnualStartDate = "02-01";
    public Calendar fyCalStart;
    public Calendar fyCalEnd;
    public Date fyStartDate;
    public Date fyEndDate;
    public int year;
    public int month;
    public int day;
    public String timeZone = "PST";
    protected  SimpleDateFormat isoSDF = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
    public  Date statusTime = null;
    public  String stringTime = "";
    public String fyName;

    /**
     * This is our lazy constructor assumes this is 02-01 for the start year and PST for the time zone
     * 
     * Assumes that the year passed is the start of the year which assigns to the fiscal year
     * 
     * I.E. 2020 would be fy21
     * 
     * @param year
     * @throws ParseException
     */
    public FiscalYear(int year) throws ParseException {
        // TODO Auto-generated constructor stub
        this.year = year;
        setYearMonth();
        setDates();
        setName();
    }

    public FiscalYear(int year, String zone) throws ParseException {
        // TODO Auto-generated constructor stub
        this.year = year;
        this.timeZone = zone;
        setYearMonth();
        setDates();
        setName();
    }
    
    /**
     * This constructor allows you to set the annualstartdate if you need to adjust the fiscal year to a new company
     * @param year
     * @param zone
     * @param annualStartDate
     * @throws ParseException
     */
    public FiscalYear(int year, String zone, String annualStartDate) throws ParseException {
        // TODO Auto-generated constructor stub
        
        this.fyAnnualStartDate = annualStartDate;
        this.year = year;
        this.timeZone = zone;
        setYearMonth();
        setDates();
        setName();
    }
    
    /**
     * This constructor allows you to set the annualstartdate if you need to adjust the fiscal year to a new company
     * However this allows you to provide the current date or date in general to confirm the true fiscal year
     * @param year
     * @param zone
     * @param annualStartDate
     * @throws Exception
     */
    public FiscalYear(Date year, String zone, String annualStartDate) throws Exception {
        // TODO Auto-generated constructor stub
        
        this.timeZone = zone;
        this.fyAnnualStartDate = annualStartDate;
        this.year = getActualYear(year);
        setYearMonth();
        setDates();
        setName();
    }
    
    /**
     * This constructor allows you to provide the current date or date in general to confirm the true fiscal year
     * Default annual start date is set in var fyAnnualStartDate
     * 
     * @param year
     * @throws Exception
     */
    public FiscalYear(Date year) throws Exception {
        // TODO Auto-generated constructor stub
        
        this.year = getActualYear(year);
        setYearMonth();
        setDates();
        setName();
    }
    
    /**
     * Gets the actual FY to be correct given the window can a Fiscal year can have two years within it
     * 
     * This tests to figure out which FY this should instantiate to given the date you are providing based on the start date and logic that
     * Fiscal Year 21 corresponds to the a lesser actual start year 
     * I.E. 2020 would be fy21
     * @param year2
     * @return
     * @throws Exception
     */
    public static int getActualYear(Date year2) throws Exception {
        // TODO Auto-generated method stub
        SimpleDateFormat isoSDFTest = new SimpleDateFormat("yyyy");
        
        FiscalYear test = new FiscalYear(Integer.parseInt(isoSDFTest.format(year2)));
        FiscalYear testBefore = new FiscalYear(Integer.parseInt(isoSDFTest.format(year2))-1);
        FiscalYear testAfter = new FiscalYear(Integer.parseInt(isoSDFTest.format(year2))+1);
        
        if ((test.getStartDateAsDate().before(year2) && test.getEndDateAsDate().after(year2)) || year2.equals(test.getStartDateAsDate()) || year2.equals(test.getEndDateAsDate())) {
            return Integer.parseInt(isoSDFTest.format(test.getStartDateAsDate()));
        }
        
        if ((testBefore.getStartDateAsDate().before(year2) && testBefore.getEndDateAsDate().after(year2)) || year2.equals(testBefore.getStartDateAsDate()) || year2.equals(testBefore.getEndDateAsDate())) {
            return Integer.parseInt(isoSDFTest.format(testBefore.getStartDateAsDate()));
        }
        
        if ((testAfter.getStartDateAsDate().before(year2) && testAfter.getEndDateAsDate().after(year2)) || year2.equals(testAfter.getStartDateAsDate()) || year2.equals(testAfter.getEndDateAsDate())) {
            return Integer.parseInt(isoSDFTest.format(testAfter.getStartDateAsDate()));
        }
        
        throw new Exception("Issue figuring window out");
    }

    private void setName() {
        // TODO Auto-generated method stub
        String fy = "FY";
        this.fyName = fy+String.valueOf(year+1).substring(2,4);
    }

    private void setYearMonth() {
        // TODO Auto-generated method stub
        String []  arr = fyAnnualStartDate.split("-");
        month = Integer.parseInt(arr[0])-1;
        day = Integer.parseInt(arr[1]);
    }

    private void setDates() throws ParseException {
        // TODO Auto-generated method stub
        isoSDF.setTimeZone(TimeZone.getTimeZone(timeZone));

        Calendar cal = Calendar.getInstance();
        cal.setTimeZone(TimeZone.getTimeZone(timeZone));
        cal.set(Calendar.YEAR, year);
        cal.set(Calendar.MONTH, month);
        cal.set(Calendar.DAY_OF_MONTH, day);
        cal.set(Calendar.HOUR_OF_DAY,0);
        cal.set(Calendar.MINUTE,0);
        cal.set(Calendar.SECOND,0);
        cal.set(Calendar.MILLISECOND,0);

        fyCalStart = cal;
        fyStartDate = cal.getTime();

        Calendar endCal = (Calendar) cal.clone();
        endCal.add(Calendar.YEAR, 1);
        endCal.add(Calendar.SECOND,-1);

        fyCalEnd = endCal;
        fyEndDate = endCal.getTime();

        statusTime = isoSDF.parse(isoSDF.format(new Date()));
        stringTime = isoSDF.format(statusTime);
    }

    public String getStartDate() {
        return isoSDF.format(fyStartDate);
    }

    public String getEndDate() {
        return  isoSDF.format(fyEndDate);
    }
    
    public Date getStartDateAsDate() {
        return fyStartDate;
    }

    public Date getEndDateAsDate() {
        return  fyEndDate;
    }

    public void shiftWindow(int shift) {
        fyCalStart.add(Calendar.YEAR, shift);
        fyCalEnd.add(Calendar.YEAR, shift);
        fyStartDate = fyCalStart.getTime();
        fyEndDate = fyCalEnd.getTime();
        year = year + shift;
        setName();
    }

    public String getQuarterStartDate(int quarter) throws Exception {
        Calendar temp =  (Calendar) fyCalStart.clone();

        quarter = validateQuarter(quarter);

        if (quarter==1) {

        } else if (quarter==2) {
            temp.add(Calendar.MONTH, 3);
        } else if (quarter==3) {
            temp.add(Calendar.MONTH, 6);
        } else {
            temp.add(Calendar.MONTH, 9);
        }

        Date tempDate = temp.getTime();
        return isoSDF.format(tempDate);
    }

    public String getQuarterEndDate(int quarter) throws Exception {
        Calendar temp = (Calendar) fyCalEnd.clone();

        quarter = validateQuarter(quarter);

        if (quarter==1) {
            temp.add(Calendar.MONTH, -9);
        } else if (quarter==2) {
            temp.add(Calendar.MONTH, -6);
        } else if (quarter==3) {
            temp.add(Calendar.MONTH, -3);
        } else {

        }

        Date tempDate = temp.getTime();
        return isoSDF.format(tempDate);
    }

    public String getMonthStartDate(int quarter, int month) throws Exception {
        Calendar temp =  (Calendar) fyCalStart.clone();

        quarter = validateQuarter(quarter);
        month = validateMonth(month);

        if (quarter==1) {
            if (month==1) {

            } else if (month==2) {
                temp.add(Calendar.MONTH, 1);
            } else {
                temp.add(Calendar.MONTH, 2);
            }
        } else if (quarter==2) {
            if (month==1) {
                temp.add(Calendar.MONTH, 3);
            } else if (month==2) {
                temp.add(Calendar.MONTH, 4);
            } else {
                temp.add(Calendar.MONTH, 5);
            }
        } else if (quarter==3) {
            if (month==1) {
                temp.add(Calendar.MONTH, 6);
            } else if (month==2) {
                temp.add(Calendar.MONTH, 7);
            } else {
                temp.add(Calendar.MONTH, 8);
            }
        } else {
            if (month==1) {
                temp.add(Calendar.MONTH, 9);
            } else if (month==2) {
                temp.add(Calendar.MONTH, 10);
            } else {
                temp.add(Calendar.MONTH, 11);
            }
        }

        Date tempDate = temp.getTime();
        return isoSDF.format(tempDate);
    }

    public String getMonthEndDate(int quarter, int month) throws Exception {
        Calendar temp = (Calendar) fyCalEnd.clone();

        quarter = validateQuarter(quarter);
        month = validateMonth(month);

        if (quarter==1) {
            if (month==1) {
                temp.add(Calendar.MONTH, -11);
            } else if (month==2) {
                temp.add(Calendar.MONTH, -10);
            } else {
                temp.add(Calendar.MONTH, -9);
            }
        } else if (quarter==2) {
            if (month==1) {
                temp.add(Calendar.MONTH, -8);
            } else if (month==2) {
                temp.add(Calendar.MONTH, -7);
            } else {
                temp.add(Calendar.MONTH, -6);
            }
        } else if (quarter==3) {
            if (month==1) {
                temp.add(Calendar.MONTH, -5);
            } else if (month==2) {
                temp.add(Calendar.MONTH, -4);
            } else {
                temp.add(Calendar.MONTH, -3);
            }
        } else {
            if (month==1) {
                temp.add(Calendar.MONTH, -2);
            } else if (month==2) {
                temp.add(Calendar.MONTH, -1);
            } else {

            }
        }

        Date tempDate = temp.getTime();
        return isoSDF.format(tempDate);
    }

    public Date getQuarterStartDateAsDate(int quarter) throws Exception {
        Calendar temp =  (Calendar) fyCalStart.clone();

        quarter = validateQuarter(quarter);

        if (quarter==1) {

        } else if (quarter==2) {
            temp.add(Calendar.MONTH, 3);
        } else if (quarter==3) {
            temp.add(Calendar.MONTH, 6);
        } else {
            temp.add(Calendar.MONTH, 9);
        }

        
        Date tempDate = temp.getTime();
        
        return tempDate;
    }

    public Date getQuarterEndDateAsDate(int quarter) throws Exception {
        Calendar temp = (Calendar) fyCalEnd.clone();

        quarter = validateQuarter(quarter);

        if (quarter==1) {
            temp.add(Calendar.MONTH, -9);
        } else if (quarter==2) {
            temp.add(Calendar.MONTH, -6);
        } else if (quarter==3) {
            temp.add(Calendar.MONTH, -3);
        } else {

        }
        
        Date tempDate = temp.getTime();
        
        return tempDate;
    }

    public Date getMonthStartDateAsDate(int quarter, int month) throws Exception {
        Calendar temp =  (Calendar) fyCalStart.clone();

        quarter = validateQuarter(quarter);
        month = validateMonth(month);

        if (quarter==1) {
            if (month==1) {

            } else if (month==2) {
                temp.add(Calendar.MONTH, 1);
            } else {
                temp.add(Calendar.MONTH, 2);
            }
        } else if (quarter==2) {
            if (month==1) {
                temp.add(Calendar.MONTH, 3);
            } else if (month==2) {
                temp.add(Calendar.MONTH, 4);
            } else {
                temp.add(Calendar.MONTH, 5);
            }
        } else if (quarter==3) {
            if (month==1) {
                temp.add(Calendar.MONTH, 6);
            } else if (month==2) {
                temp.add(Calendar.MONTH, 7);
            } else {
                temp.add(Calendar.MONTH, 8);
            }
        } else {
            if (month==1) {
                temp.add(Calendar.MONTH, 9);
            } else if (month==2) {
                temp.add(Calendar.MONTH, 10);
            } else {
                temp.add(Calendar.MONTH, 11);
            }
        }
        
        Date tempDate = temp.getTime();
        
        return tempDate;
    }

    public Date getMonthEndDateAsDate(int quarter, int month) throws Exception {
        Calendar temp = (Calendar) fyCalEnd.clone();

        quarter = validateQuarter(quarter);
        month = validateMonth(month);

        if (quarter==1) {
            if (month==1) {
                temp.add(Calendar.MONTH, -11);
            } else if (month==2) {
                temp.add(Calendar.MONTH, -10);
            } else {
                temp.add(Calendar.MONTH, -9);
            }
        } else if (quarter==2) {
            if (month==1) {
                temp.add(Calendar.MONTH, -8);
            } else if (month==2) {
                temp.add(Calendar.MONTH, -7);
            } else {
                temp.add(Calendar.MONTH, -6);
            }
        } else if (quarter==3) {
            if (month==1) {
                temp.add(Calendar.MONTH, -5);
            } else if (month==2) {
                temp.add(Calendar.MONTH, -4);
            } else {
                temp.add(Calendar.MONTH, -3);
            }
        } else {
            if (month==1) {
                temp.add(Calendar.MONTH, -2);
            } else if (month==2) {
                temp.add(Calendar.MONTH, -1);
            } else {

            }
        }
        
        Date tempDate = temp.getTime();
        
        return tempDate;
    }
    
    /**
     * Gets the current FY year based on start year
     * @return
     */
    public String getFYName() {
        return fyName;
    }

    /**
     * Gets a systematic name for the FY year plus quarter
     * @param quarter
     * @return
     * @throws Exception
     */
    public String getQuarterName(int quarter) throws Exception {
        quarter=validateQuarter(quarter);
        return fyName+".Q"+quarter;
    }

    /**
     * Gets a systematic name for the FY year, quarter and month
     * @param quarter
     * @param month
     * @return
     * @throws Exception
     */
    public String getMonthName(int quarter, int month) throws Exception {
        quarter=validateQuarter(quarter);
        month=validateMonth(month);
        return fyName+".Q"+quarter+".M"+month;
    }

    public int validateQuarter(int quarter) throws Exception {
        int [] test = {1,2,3,4};

        for(int i:test) {
            if (i==quarter) {
                return i;
            }
        }

        throw new Exception("Invalid Quarter");
    }

    public int validateMonth(int month) throws Exception {
        int [] test = {1,2,3};

        for(int i:test) {
            if (i==month) {
                return i;
            }
        }

        throw new Exception("Invalid Month");
    }

    /**
     * Method tests if given a string format does it belong to the current fiscalyear
     * Does not say if its a future or past just returns true or false
     * @param fy
     * @return
     * @throws Exception 
     */
    public static boolean inCurrentFyWindow(String fy) throws Exception {
        Date yearTest = new Date();
        FiscalYear test = new FiscalYear(yearTest);

        if (fy.length()==8 ||fy.length()==6) {
            //FY21Q1M1
            String fyName = fy.split("Q")[0];

            if (test.getFYName().toLowerCase().equals(fyName.toLowerCase())) {
                return true;
            } else {
                return false;
            }

        } else {
            //FY21
            if (test.getFYName().toLowerCase().equals(fy.toLowerCase())) {
                return true;
            } else {
                return false;
            }
        }
    }
    
    /**
     * Method tests if the string for FiscalYear being passed has passed or not based on the current FiscalYear
     * 
     * This can test FY year, FY year, quarter and finally FY year, quarter and month combinations
     * 
     * @param fy
     * @return
     * @throws Exception
     */
    public static boolean hasWindowHappenedFully(String fy) throws Exception {
        Date yearTest = new Date();
        
        if (fy.length()==8) {
            //FY21Q1M1
            String fyName = "20" + fy.substring(2, 4);
            int quarter = Integer.parseInt(fy.substring(5, 6));
            int month = Integer.parseInt(fy.substring(7, 8));
            
            FiscalYear yQM = new FiscalYear(Integer.parseInt(fyName)-1);
            
            if (yearTest.after(yQM.getMonthEndDateAsDate(quarter, month))) {
                return true;
            } else {
                return false;
            }
        } else if (fy.length()==6) {
            //FY21Q1
            String fyName = "20" + fy.substring(2, 4);
            int quarter = Integer.parseInt(fy.substring(5, 6));

            FiscalYear yQM = new FiscalYear(Integer.parseInt(fyName)-1);

            if (yearTest.after(yQM.getQuarterEndDateAsDate(quarter))) {
                return true;
            } else {
                return false;
            }
        } else {
            //FY21
            String fyName = "20" + fy.substring(2, 4);

            FiscalYear yQM = new FiscalYear(Integer.parseInt(fyName)-1);
            
            if (yearTest.after(yQM.getEndDateAsDate())) {
                return true;
            } else {
                return false;
            }
        }
    }
    
    public static String getCurrentFiscalYear() throws Exception {
        Date yearTest = new Date();
        FiscalYear test = new FiscalYear(yearTest);
        return  test.getFYName();
    }
    
    public static String getCurrentFiscalYearQuarter() throws Exception {
        Date yearTest = new Date();
        FiscalYear test = new FiscalYear(yearTest);
        
        for(int q=1; q<=4; q++ ) {
            for(int m=1; m<=3; m++ )
                if (test.getMonthStartDateAsDate(q, m).before(yearTest) && test.getMonthEndDateAsDate(q, m).after(yearTest)) {
                    return test.getFYName()+".Q"+q;
                }
            
        }
        
        return test.getFYName();
    }
    
    public static String getCurrentFiscalYearQuarterMonth() throws Exception {
        Date yearTest = new Date();
        FiscalYear test = new FiscalYear(yearTest);
        
        for(int q=1; q<=4; q++ ) {
            for(int m=1; m<=3; m++ )
                if (test.getMonthStartDateAsDate(q, m).before(yearTest) && test.getMonthEndDateAsDate(q, m).after(yearTest)) {
                    return test.getFYName()+".Q"+q+".M"+m;
                }
            
        }
        
        return test.getFYName();
    }
    
    public static String getFiscalYear(Date year2) throws Exception {
        FiscalYear test = new FiscalYear(year2);
        return test.getFYName();
    }
    
    public static String getFiscalYearQuarter(Date year2) throws Exception {
        FiscalYear test = new FiscalYear(year2);
        
        for(int q=1; q<=4; q++ ) {
            for(int m=1; m<=3; m++ )
                if (test.getMonthStartDateAsDate(q, m).before(year2) && test.getMonthEndDateAsDate(q, m).after(year2) || year2.equals(test.getMonthStartDateAsDate(q, m)) || year2.equals(test.getMonthEndDateAsDate(q, m))) {
                    return test.getFYName()+".Q"+q+".M"+m;
                }
            
        }
        
        return test.getFYName();
    }
    
    public static String getFiscalYearQuarterMonth(Date year2) throws Exception {
        FiscalYear test = new FiscalYear(year2);
        
        for(int q=1; q<=4; q++ ) {
            for(int m=1; m<=3; m++ )
                if (test.getMonthStartDateAsDate(q, m).before(year2) && test.getMonthEndDateAsDate(q, m).after(year2) || year2.equals(test.getMonthStartDateAsDate(q, m)) || year2.equals(test.getMonthEndDateAsDate(q, m))) {
                    return test.getFYName()+".Q"+q+".M"+m;
                }
            
        }
        
        return test.getFYName();
    }

}