https://github.com/bahmanm/persianutils
A collection of utilities for Scala/Java developers who are targeting Persian (Farsi) speaking users.
https://github.com/bahmanm/persianutils
date farsi java localization scala
Last synced: 19 days ago
JSON representation
A collection of utilities for Scala/Java developers who are targeting Persian (Farsi) speaking users.
- Host: GitHub
- URL: https://github.com/bahmanm/persianutils
- Owner: bahmanm
- License: other
- Created: 2013-12-23T04:25:21.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2025-04-01T11:48:47.000Z (about 1 month ago)
- Last Synced: 2025-04-01T12:38:51.830Z (about 1 month ago)
- Topics: date, farsi, java, localization, scala
- Language: Scala
- Homepage: https://matrix.to/#/#persianutils:matrix.org
- Size: 95.7 KB
- Stars: 29
- Watchers: 5
- Forks: 8
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# 1 Introduction
[](https://dl.circleci.com/status-badge/redirect/circleci/UMKeFZ8ns9T9vi5aquTfVT/BwGU1tm7aeza7w99ccaEMW/tree/master)
[](https://matrix.to/#/#github-bahmanm-persianutils:matrix.org)




[](https://app.fossa.com/projects/git%2Bgithub.com%2Fbahmanm%2Fpersianutils?ref=badge_shield)A collection of utilities for Scala/Java developers who are targeting Persian (Farsi) speaking users.
![]()
### 1.1 Scala Compatibility
| ⬇ persianutils ❚ scala ➡ | 2.10.x | 2.11.x | 2.12.x | 2.13.x | 3.x |
|----------------------------|--------|--------|--------|--------|------|
| 5.x | ❌ | ❌ | ✅ | ✅ | ✅ |
| 4.x | ❌ | ✅ | ✅ | ✅ | ❌ |
| 3.x | ❌ | ✅ | ✅ | ❌ | ❌ |
| 2.x | ✅ | ✅ | ❌ | ❌ | ❌ |# 2 Adding To Your Project
### 2.1 SBT
```scala
libraryDependencies ++= Seq(
"com.bahmanm" %% "persianutils" % "5.0"
)
```### 2.2 Maven
With Scala 3.x:
```xml
com.bahmanm
persianutils_3
5.0
```
With Scala 2.13.x:
```xml
com.bahmanm
persianutils_2.13
5.0
```
With Scala 2.12.x:
```xml
com.bahmanm
persianutils_2.12
5.0
```
## 3 What Is Included?
This is a short review of what you will find in _persianutils_:
### 3.1 DateConverter
`com.bahmanm.persianutils.DateConverter` is the Scala port of the original algorithm (in Fortran) [The Persian calendar for 3000 years](http://www.astro.uni.torun.pl/~kb/Papers/EMP/PersianC-EMP.htm).
#### 3.1.1 Scala
```scala
import com.bahmanm.persianutils.DateConverter._// NOTE: months and days are 1-indexed, i.e. December is 12 or Farvardin is 1
val gDate1 = SimpleDate(2013, 12, 11)
val pDate1 = gregorianToPersian(gDate1)
print(pDate1) // OUTPUT: SimpleDate(1392,9,20) -> 20om Azar 1392val pDate2 = SimpleDate(1392, 1, 1)
val gDate2 = persianToGregorian(pDate2)
print(gDate2) // OUTPUT: SimpleDate(2013,3,21) -> March 21st 2013val d = java.util.Calendar.getInstance().getTime()
val gDate3 = SimpleDate(date) // iniatlising from a java.util.Date
val pDate3 = gregorianToPersian(gDate3)val ds = "1392/09/24"
val pDate4 = SimpleDate(ds) // initialising from a String
val gDate4 = persianToGregorian(pDate4)
```#### 3.1.2 Java
```java
import com.bahmanm.persianutils.DateConverter;public class Main {
public static void main(String[] args) {
DateConverter.SimpleDate pd1 = new DateConverter.SimpleDate(1392, 11, 11);
DateConverter.SimpleDate gd1 = DateConverter.persianToGregorian(pd1);
System.out.println(gd1);DateConverter.SimpleDate gd2 = new DateConverter.SimpleDate(2014, 2, 4);
DateConverter.SimpleDate pd2 = DateConverter.gregorianToPersian(gd2);
System.out.println(pd2);
}}
```### 3.2 NumToWord
```scala
import com.bahmanm.persianutils.NumToWordassert(NumToWord(100) == "صد")
assert(NumToWord(299792458) == "دویست و نود و نه میلیون و هفتصد و نود و دو هزار و چهارصد و پنجاه و هشت")
```## License
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fbahmanm%2Fpersianutils?ref=badge_large)