PrimeCalendar alternatives and similar libraries
Based on the "Misc" category.
Alternatively, view PrimeCalendar alternatives based on common mentions on social networks and blogs.
-
jclasslib
jclasslib bytecode viewer is a tool that visualizes all aspects of compiled Java class files and the contained bytecode. -
kotlin-logging
Lightweight logging framework for Kotlin. Used as a wrapper for slf4j with Kotlin extensions. -
kotlinx-datetime
A multiplatform Kotlin library for working with date and time. -
klock
Consistent and portable date and time utilities for multiplatform kotlin (JVM, JS and Common). -
kotlinx.atomicfu
The idiomatic way to use atomic operations in Kotlin. -
kotlin-telegram-bot
A wrapper for the Telegram Bot API written in Kotlin. -
kotlinx.reflect.lite
Lightweight library allowing to introspect basic stuff about Kotlin symbols. -
Humanizer.jvm
Humanizer.jvm meets all your jvm needs for manipulating and displaying strings, enums, dates, times, timespans, numbers and quantities. -
actions-on-google-kotlin
Port of official Node.js SDK to Kotlin. Complete with all features and tests and nearly identical API. -
klutter
A mix of random small libraries for Kotlin, the smallest reside here until big enough for their own repository. -
SimpleDNN
SimpleDNN is a machine learning lightweight open-source library part of KotlinNLP and has been designed to support relevant neural network architectures in natural language processing tasks. -
kassava
This library provides some useful kotlin extension functions for implementing toString() and equals() without all of the boilerplate. -
kotlin-futures
A collections of extension functions to make the JVM Future, CompletableFuture, ListenableFuture API more functional and Kotlin like. -
units-of-measure
A type-safe dimensional analysis library for Kotlin. -
kasechange
Multiplatform Kotlin library to convert strings between various case formats including Camel Case, Snake Case, Pascal Case and Kebab Case -
kotlin-pluralizer
Kotlin extension to pluralize and singularize strings.
Get performance insights in less than 4 minutes
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest. Visit our partner's website for more details.
Do you think we are missing an alternative of PrimeCalendar or a related project?
README
PrimeCalendar
:zap:
PrimeCalendar
provides all the java.util.Calendar
functionalities for Persian
, Hijri
, and Japanese
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 which is used in most of the world. | |Japanese| JapaneseCalendar | The calendar which is used in Japan. |
[](static/prime_logo.png)
Download
PrimeCalendar
is available on bintray to download using build tools systems.
• Gradle
Add the following lines to your build.gradle
file:
repositories {
jcenter()
}
dependencies {
implementation 'com.aminography:primecalendar:1.3.0'
}
• Maven
Add the following lines to your pom.xml
file:
<repositories>
<repository>
<id>jcenter</id>
<url>https://jcenter.bintray.com/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.aminography</groupId>
<artifactId>primecalendar</artifactId>
<version>1.3.0</version>
</dependency>
</dependencies>
Usage
Calendar objects can be instantiated by the class constructors or using CalendarFactory
.
Java
PrimeCalendar calendar = new PersianCalendar(); // or PrimeCalendar calendar = CalendarFactory.newInstance(CalendarType.PERSIAN);
Kotlin
val calendar = HijriCalendar() // or val calendar = CalendarFactory.newInstance(CalendarType.HIJRI)
• Functionalities
Exactly 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)
println(civil.longDateString)
civil.set(Calendar.DAY_OF_YEAR, 192)
println(civil.longDateString)
civil.add(Calendar.WEEK_OF_YEAR, 14)
println(civil.longDateString)
civil.roll(Calendar.DAY_OF_WEEK, -3)
println(civil.longDateString)
---------------------------
> 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()
// Converting calendar instance to JapaneseCalendar:
val japanese = calendar.toJapanese()
Also, it is possible to convert an instance of java.util.Calendar
to an instance of PrimeCalendar
. For example:
import java.util.Calendar
val calendar = Calendar.getInstance()
// Converting to PersianCalendar:
val persian = calendar.toPersian()
• Kotlin 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
:
get
val year = calendar.get(Calendar.YEAR)
// equivalent operations: val year = calendar[Calendar.YEAR] val year = calendar.year
> set
```kotlin
calendar.set(Calendar.MONTH, 7)
// equivalent operations:
calendar[Calendar.MONTH] = 7
calendar.set(Month(7))
calendar.set(7.month)
calendar.month = 7
add
calendar.add(Calendar.DAY_OF_MONTH, 27)
// equivalent operations: calendar[Calendar.DAY_OF_MONTH] += 27 calendar += DayOfMonth(27) calendar += 27.dayOfMonth
<br/>
### • 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.
```kotlin
val persian = PersianCalendar()
println(persian.longDateString)
---------------------------
> پنجشنبه، ۲۳ خرداد ۱۳۹۸
val persian = PersianCalendar(Locale.ENGLISH)
println(persian.longDateString)
---------------------------
> Thursday, 23 Khordad 1398
Third Party Libraries
• ThreeTen-Backport (https://www.threeten.org/threetenbp)
Change Log
Version 1.3.0
- Adding getter/setter field for all the calendar fields, such as dayOfWeek, hour, etc.
- Adding date conversion extension functions for
java.util.Calendar
instances. - Adding calendar fields extensions for numbers, e.g.
calendar += 27.dayOfMonth
Version 1.2.21
- Japanese month names and other temporal names are changed.
- Month constants are added into calendar classes.
License
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
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*Note that all licence references and agreements mentioned in the PrimeCalendar README section above
are relevant to that project's source code only.