All Projects → mfathi91 → persian-date-time

mfathi91 / persian-date-time

Licence: MIT license
Persian Date Time

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to persian-date-time

gahshomar
A Persian (Jalali/Farsi) calendar for Linux
Stars: ✭ 69 (+27.78%)
Mutual labels:  calendar, persian-calendar, jalali-calendar, iranian-calendar
JalaliCalendar
Jalali Calendar for java
Stars: ✭ 76 (+40.74%)
Mutual labels:  persian-calendar, jalali-calendar, gregorian
libcalendars
Collection of calendar arithmetic algorithms
Stars: ✭ 38 (-29.63%)
Mutual labels:  jalali-calendar, gregorian
pcal
Command line tool to convert Gregorian calendar dates to Persian calendar dates
Stars: ✭ 22 (-59.26%)
Mutual labels:  persian-calendar, jalali-calendar
shamsi date
A Flutter and Dart package for using Jalali (Shamsi, Solar, Persian or Jalaali) calendar. You can convert, format and manipulate Jalali and Gregorian (Miladi) date and times.
Stars: ✭ 59 (+9.26%)
Mutual labels:  calendar, gregorian
PrimeCalendar
PrimeCalendar provides all of the java.util.Calendar functionalities for Persian, Hijri, and ... dates. It is also possible to convert dates to each other.
Stars: ✭ 45 (-16.67%)
Mutual labels:  calendar, persian-calendar
GDCalendar
Calendar component with RTL languages written in swift
Stars: ✭ 27 (-50%)
Mutual labels:  calendar, persian-calendar
calendarium-romanum
liturgical calendar library (Roman Catholic, post-Vatican II)
Stars: ✭ 37 (-31.48%)
Mutual labels:  calendar
php-json-schema-model-generator
Creates (immutable) PHP model classes from JSON-Schema files including all validation rules as PHP code
Stars: ✭ 36 (-33.33%)
Mutual labels:  immutable
nepali date picker
Material Style Date Picker with Bikram Sambat(Nepali) Calendar Support. Supports both Android and ios.
Stars: ✭ 30 (-44.44%)
Mutual labels:  calendar
wxapp-boilerplate
微信小程序开发脚手架 (ES6, Redux, Immutable-js, Async/await, Promise, Reselect, Babel, ESLint, Stylelint, Gulp ... )
Stars: ✭ 35 (-35.19%)
Mutual labels:  immutable
svelte-fullcalendar
A Svelte component wrapper around FullCalendar
Stars: ✭ 123 (+127.78%)
Mutual labels:  calendar
markdown-it-calendar
Automatically produced markdown-it-calendar
Stars: ✭ 23 (-57.41%)
Mutual labels:  calendar
laravel-fullcalendar
Laravel Fullcalendar component
Stars: ✭ 57 (+5.56%)
Mutual labels:  calendar
prodcal ics
Производственный календарь в формате ics
Stars: ✭ 23 (-57.41%)
Mutual labels:  calendar
ionic4-date-picker
Calendar date picker for Ionic4 apps
Stars: ✭ 24 (-55.56%)
Mutual labels:  calendar
KM-MiniProgram
mini program for keep memory
Stars: ✭ 15 (-72.22%)
Mutual labels:  calendar
thymeflow
Installer for Thymeflow, a personal knowledge management system.
Stars: ✭ 27 (-50%)
Mutual labels:  calendar
go-sunrise
Go package for calculating the sunrise and sunset times for a given location
Stars: ✭ 42 (-22.22%)
Mutual labels:  calendar
hebcal-es6
Hebcal, a perpetual Jewish Calendar (ES6)
Stars: ✭ 45 (-16.67%)
Mutual labels:  calendar

Persian Date Time

Maven Central codecov Javadocs

This library is an implementation of Solar Hijri calendar (also known as Jalali calendar or Persian calendar). It is an immutable and thread-safe implementation of Persian calendar system, and can be used in multi-threaded programs.

As Java does not support Persian calendar, this library can be used in the applications that need Persian calendar system. Purpose of this library is to provide an immutable and easy API (that is similar to JDK 8 date and time API) for Persian calendar system. This class has been implemented the same as internal JDK calendars such as JapaneseDate.

Instructions

Maven

Include the following to your dependency list:

<dependency>
  <groupId>com.github.mfathi91</groupId>
  <artifactId>persian-date-time</artifactId>
  <version>4.2.1</version>
</dependency>

Usage

PersianDate: The base class for Persian date handling. Here are some trivial examples on how to use different functionalities of PersianDate

// Instantiate 
PersianDate today = PersianDate.now();
PersianDate persianDate1 = PersianDate.of(1396, 7, 15);
PersianDate persianDate2 = PersianDate.of(1396, PersianMonth.MEHR, 15);

// Convert
PersianDate persianDate5 = PersianDate.of(1397, 5, 11);
LocalDate gregDate = persianDate.toGregorian();    // => '2018-08-02'
PersianDate persianDate6 = PersianDate.fromGregorian(gregDate);  //  => '1397/05/11'

// Parse
PersianDate persianDate3 = PersianDate.parse("1400-06-15");    // From the standard format
PersianDate persianDate4 = PersianDate.parse("1400/06/15", DateTimeFormatter.ofPattern("yyyy/MM/dd"));    // From a desired format

// Format
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd");
dtf.format(PersianDate.now());    // => e.g. '1396/05/10'

PersianDateTime: A wrapper class around PersianDate and LocalTime to make the date-time handling more convenient. Here are some trivial examples of PersianDateTime

// Instantiate
PersianDateTime now = PersianDateTime.now();    // => 'now' will contain the instantiated date and time
PersianDateTime persianDateTime2 = PersianDateTime.of(PersianDate.of(1400, PersianMonth.DEY, 15), LocalTime.of(17, 55, 19));
PersianDateTime persianDateTime3 = PersianDateTime.of(1400, PersianMonth.DEY, 15, 17, 55, 19);

// Parse
PersianDateTime persianDateTime4 = PersianDateTime.parse("1401-06-10T08:35:11");    // From the standard format
PersianDateTime persianDateTime5 = PersianDateTime.parse("1400-06-15_11-38-43", DateTimeFormatter.ofPattern("yyyy-MM-dd_HH-mm-ss"));    // From a desired format

// Format
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
dtf.format(PersianDateTime.now());    // => e.g. '1396/05/10 14:05:11'

The conversion algorithm from Solar Hijri calendar to Gregorian calendar and vice versa, is adopted from here.

Requirements

This version of Persian Date Time requires:

  • Java SE 8

License

This library is released under MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].