Fiscal Year

Utility library to work with fiscal years.

License

License

GroupId

GroupId

com.github.sebhoss
ArtifactId

ArtifactId

fiscal-year
Last Version

Last Version

2.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

Fiscal Year
Utility library to work with fiscal years.
Project URL

Project URL

https://github.com/sebhoss/fiscal-year
Project Organization

Project Organization

sebhoss
Source Code Management

Source Code Management

https://github.com/sebhoss/fiscal-year

Download fiscal-year

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.sebhoss/fiscal-year/ -->
<dependency>
    <groupId>com.github.sebhoss</groupId>
    <artifactId>fiscal-year</artifactId>
    <version>2.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.sebhoss/fiscal-year/
implementation 'com.github.sebhoss:fiscal-year:2.0.0'
// https://jarcasting.com/artifacts/com.github.sebhoss/fiscal-year/
implementation ("com.github.sebhoss:fiscal-year:2.0.0")
'com.github.sebhoss:fiscal-year:jar:2.0.0'
<dependency org="com.github.sebhoss" name="fiscal-year" rev="2.0.0">
  <artifact name="fiscal-year" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.sebhoss', module='fiscal-year', version='2.0.0')
)
libraryDependencies += "com.github.sebhoss" % "fiscal-year" % "2.0.0"
[com.github.sebhoss/fiscal-year "2.0.0"]

Dependencies

compile (1)

Group / Artifact Type Version
com.github.sebhoss : suppress-warnings jar

test (1)

Group / Artifact Type Version
junit : junit jar

Project Modules

There are no modules declared in this project.

Fiscal-Year Discuss on Google Groups Chat on IRC

CC Zero Maven Central Read JavaDocs Repository size Open Hub statistics

Build Status Code Coverage Technical Debt Coverity Scan Result Codacy Code Quality Can this project be forked? Is this thing still maintained? Bounties on open tickets

Your company doesn’t work from January 1 to December 31? Try fiscal-year, a small Java library which converts calendar-year based dates to corresponding dates in a fiscal year.

Features

  • Immutable data structure

  • Convert from/to Java 8 LocalDate

  • Math operations like plusDays, minusWeeks

  • Factories to create/configure

Development Status

All currently required feature are implemented. This project is in maintenance mode.

Usage

First create a FiscalYearFactory which holds the configuration of your company’s fiscal year:

// fiscal year starts at month 11 of the 'previous' year
FiscalYearFactory earlyYearFactory = FiscalYears.earlyFiscalYear(11);

// fiscal year starts at month 3 in the 'current' year
FiscalYearFactory lateYearFactory = FiscalYears.lateFiscalYear(3);

Then use this factory to convert a calendar-year based LocalDate to a corresponding FiscalDate:

LocalDate calendarDate = LocalDate.now();
FiscalDate fiscalDate = factory.createFromCalendarDate(calendarDate);

Use fiscal-year based values directly to create an instance of FiscalDate:

FiscalDate fiscalDate = factory.create(2015, 3, 25);

Query the newly created FiscalDate to retrieve the usual suspects of attributes:

int fiscalYear = fiscalDate.getFiscalYear();
int fiscalMonth = fiscalDate.getFiscalMonth();
int fiscalDayOfYear = fiscalDate.getFiscalDayOfYear();
int fiscalWeekOfWeekyear = fiscalDate.getFiscalWeekOfWeekyear();

int calendarYear = fiscalDate.getCalendarYear();
int calendarMonth = fiscalDate.getCalendarMonth();
int calendarDayOfMonth = fiscalDate.getCalendarDayOfMonth();
int calendarDayOfYear = fiscalDate.getCalendarDayOfYear();
int calendarWeekOfWeekyear = fiscalDate.getCalendarWeekOfWeekyear();

Do some math with dates as follows:

FiscalDate newDate = fiscalDate.plusYears(int years);
FiscalDate newDate = fiscalDate.plusMonths(int months);
FiscalDate newDate = fiscalDate.plusWeeks(int weeks);
FiscalDate newDate = fiscalDate.plusDays(int days);
FiscalDate newDate = fiscalDate.minusYears(int years);
FiscalDate newDate = fiscalDate.minusMonths(int months);
FiscalDate newDate = fiscalDate.minusWeeks(int weeks);
FiscalDate newDate = fiscalDate.minusDays(int days);

Or finally convert it back to a LocalDate:

LocalDate calendarDate = fiscalDate.asLocalDate();

Integration

To use this project just declare the following dependency inside your POM:

<dependency>
  <groupId>de.xn--ho-hia.utils.fiscal_year</groupId>
  <artifactId>fiscal-year</artifactId>
  <version>${version.fiscal-year}</version>
</dependency>

Replace ${version.fiscal-year} with the latest release. This project follows the semantic versioning guidelines.

Compatibility

This project is compatible with the following Java versions:

Table 1. Java compatibility
1.X.Y 2.X.Y 3.X.Y

Java 8

License

To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.

You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see http://creativecommons.org/publicdomain/zero/1.0/.

Versions

Version
2.0.0
1.0.4
1.0.3
1.0.1
1.0.0