Skip to content
PrimeCalendar provides all of java.util.Calendar functionalities for Persian and Hijri dates. It is also possible to convert dates to each other.
Branch: master
Clone or download
Latest commit dca8974 Jun 20, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
gradle Initial Commit May 23, 2019
java-sample-app Improving Readme. Jun 14, 2019
library Updating Readme Jun 20, 2019
sample-app Updating Readme Jun 20, 2019
static Initial Commit May 23, 2019
.gitignore Initial Commit May 23, 2019 Initial Commit May 23, 2019 Updating Readme Jun 20, 2019
build.gradle Updating Readme Jun 20, 2019 Initial Commit May 23, 2019
gradlew Initial Commit May 23, 2019
gradlew.bat Initial Commit May 23, 2019 Initial Commit May 23, 2019
settings.gradle Initial Commit May 23, 2019

PrimeCalendar ⚡️

PrimeCalendar provides all the java.util.Calendar functionalities for Persian and Hijri dates. PrimeCalendar can be used in every JVM-based projects such as Java/kotlin applications, Android apps, etc.

This library contains three types of calendar systems as well as their conversion to each other.

Calendar System Provider Class Descriptions
Iranian PersianCalendar The most accurate solar calendar in use today.
Islamic HijriCalendar A lunar calendar consisting of 12 lunar months in a year of 354 or 355 days.
Gregorian CivilCalendar The common calendar used in most of the world.


PrimeCalendar is available on bintray to download using build tools systems.

• Gradle

Add the following lines to your build.gradle file:

repositories {
dependencies {
    implementation 'com.aminography:primecalendar:1.2.13'

• Maven

Add the following lines to your pom.xml file:




Calendar objects can be instantiated by the class constructors or using CalendarFactory.


PrimeCalendar calendar = new PersianCalendar();
// or
PrimeCalendar calendar = CalendarFactory.newInstance(CalendarType.PERSIAN);


val calendar = HijriCalendar()
// or
val calendar = CalendarFactory.newInstance(CalendarType.HIJRI)

• Functionalities

Almost all of the standard Calendar functionalities are implemented in PrimeCalendar including set, add, roll, etc. To see list of methods and fields, refer to the wiki page.

val civil = CivilCalendar()
civil.set(2019, 5, 17)

civil.set(Calendar.DAY_OF_YEAR, 192)

civil.add(Calendar.WEEK_OF_YEAR, 14)

civil.roll(Calendar.DAY_OF_WEEK, -3)

> Monday, 17 June 2019
> Thursday, 11 July 2019
> Thursday, 17 October 2019
> Monday, 14 October 2019

• Date Conversion

Conversion of dates to each other is simply possible by calling the converter methods.

// Converting calendar instance to PersianCalendar:
val persian = calendar.toPersian()

// Converting calendar instance to HijriCalendar:
val hijri = calendar.toHijri()

// Converting calendar instance to CivilCalendar:
val civil = calendar.toCivil()

• Operators

There is a different way to use get, set, and add methods. Using operators you can do it much simpler. Suppose that the calendar is an instance of PrimeCalendar:


val year = calendar.get(Calendar.YEAR)

// equivalent operation:
val year = calendar[Calendar.YEAR]


calendar.set(Calendar.MONTH, 7)

// equivalent operation:
calendar[Calendar.MONTH] = 7


calendar.add(Calendar.DAY_OF_MONTH, 27)

// equivalent operation:
calendar[Calendar.DAY_OF_MONTH] += 27

• Localization

You can localize digits, month names, and week day names by passing locale in constructor. For Persian and Hijri calendars, the default locale is set to Farsi and Arabic respectively.

val persian = PersianCalendar()

> پنج‌شنبه، ۲۳ خرداد ۱۳۹۸
val persian = PersianCalendar(Locale.ENGLISH)

> Thursday, 23 Khordad 1398

Third Party Libraries

• ThreeTen-Backport (


Copyright 2019 Mohammad Amin Hassani.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.
You can’t perform that action at this time.