You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Sebastian Hoß 78689cfea5 fixed potential bogus int->long conversation 3 years ago
AUTHORS sign waiver 4 years ago
build/docker update docker build env 3 years ago
src fixed potential bogus int->long conversation 3 years ago
.gitignore ignore ansible markers 3 years ago
.travis.yml update badges & travis config 3 years ago
CHANGELOG.asciidoc fix links in changelog 3 years ago
CODE_OF_CONDUCT.asciidoc md -> asciidoc 3 years ago
CONTRIBUTING.asciidoc add changelog, coc & contributing files 3 years ago
LICENSE update license to CC0 4 years ago
Makefile add update-maintenance-badge goal 3 years ago
README.asciidoc fixed githubs mishandling of "--" 3 years ago
bnd.bnd add bnd file 3 years ago
maven-version-rules.xml add m-version-rules 4 years ago
pom.xml Update to latest parent 3 years ago


= Fiscal-Year image:["Discuss on Google Groups", link="!forum/metio"] image:["Chat on IRC", link=""]
Sebastian Hoß <[@sebhoss]>
:github-org: sebhoss
:project-name: fiscal-year
:project-group: de.xn--ho-hia.utils.fiscal_year
:coverity-project: 9338
:codacy-project: cd259740862044fa9d06e7788b7d577f
:toc-placement: preamble

image:["CC Zero", link=""]
pass:[<span class="image"><a class="image" href=""><img src="" alt="Maven Central"></a></span>]
pass:[<span class="image"><a class="image" href=""><img src="" alt="Read JavaDocs"></a></span>]
image:{github-org}/{project-name}&style=flat-square["Repository size"]
image:{project-name}/widgets/project_thin_badge.gif["Open Hub statistics", link="{project-name}"]

image:{github-org}/job/{project-name}/job/{project-name}_verify.svg?style=flat-square["Build Status", link="{github-org}/job/{project-name}/"]
pass:[<span class="image"><a class="image" href=""><img src="" alt="Code Coverage"></a></span>]
pass:[<span class="image"><a class="image" href=""><img src="" alt="Technical Debt"></a></span>]
image:{coverity-project}.svg?style=flat-square["Coverity Scan Result", link="{github-org}-{project-name}"]
image:{codacy-project}.svg?style=flat-square["Codacy Code Quality", link="{project-name}"]
image:["Can this project be forked?", link="{github-org}&r={project-name}"]
image:["Is this thing still maintained?"]
image:["Bounties on open tickets", link=""]

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 link:[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:

[source, java]
// 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`:

[source, java]
LocalDate calendarDate =;
FiscalDate fiscalDate = factory.createFromCalendarDate(calendarDate);

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

[source, java]
FiscalDate fiscalDate = factory.create(2015, 3, 25);

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

[source, java]
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:

[source, java]
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`:

[source, java]
LocalDate calendarDate = fiscalDate.asLocalDate();

=== Integration

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

[source, xml, subs="attributes,verbatim"]

Replace `${version.fiscal-year}` with the link:++[latest release]. This project follows the link:[semantic versioning guidelines].

=== Compatibility

This project is compatible with the following Java versions:

.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

== Mirrors