Skip to content

AagitoEx/nepdate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nepdate

A Java 8 Nepali date converter library. Already used in production by compose-nepcal, a calender UI library.

Available on maven central

Using gradle

implementation 'io.github.aagitoex:nepdate:0.0.1-beta01'

OR

Maven

<dependency>
  <groupId>io.github.aagitoex</groupId>
  <artifactId>nepdate</artifactId>
  <version>0.0.1-alpha02</version>
</dependency>

Use cases

Conversion

//from AD to BS
NepDate nepDate = fromADToBS(LocalDate.now());
int year = nepDate.getYear();
int month = nepDate.getMonth();
int day = nepDate.getDay();

//from BS to AD
LocalDate date =  fromBSToAD(NepDate.now());

Working with NepDate only

//static helpers
NepDate nepDate = NepDate.now();
NepDate nepDate = NepDate.MAX;
NepDate nepDate = NepDate.MIN;
int daysInMonth = NepDate.getDaysInMonth(year, month);
int daysInYear = NepDate.getDaysInYear(year);

//addition and subtraction
nepDate.plusDays(10); //addition
nepDate.plusDays(-5); //subtraction
nepDate.plusMonths(34);
nepDate.plusYears(10);

//count days
nepDate.daysBetween(NepDate.now());

//get AD equivalent
LocalDate date = nepDate.getAD();

//supports comparision through java's `Comparable<>` interface
Arrays.sort(nepDateArray);

Documentation work in progress