Home

Awesome

Dint

Dint is a minimalistic library to handle dates as easy as you handle simple integers.

Dint is an integer which contains date in a human-readable integer format: YYYYMMDD.

Example: 20140912 = September 12, 2014

Benefits are obvious:

Usage

int dint = Dint.create(2014, 9, 12);  // creates a dint
Integer.toString(dint);               // "20140912" - human-readable

Dint.addDays(dint, 199);              // adds 199 days to a dint

if (dint1 < dint2)                    // Simple comparison

int daysBetween = Dint.diff(20150912, 20140912); // = 365

Date asDate = Dint.toDate(dint);      // Simple conversion

Dint.year(20140912);  // 2014
Dint.month(20140912); // 9
Dint.day(20140912);   // 12

Dint.compose(2014, 13, 12);       // 20150112!
Dint.compose(2013, 9, 12 + 365);  // 20140912!

Dint.addMonths(20140930, 1);       // 20141030
Dint.addMonthsExtend(20140930, 1); // 20141031 keeps the last day of month!

And more! I just simple advise you to jump to the source code itself: Dint.java

Include

compile 'info.android15.dint:dint:1.0.3'