Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print Hijrah months in java?

Any enum to associate below months?

1 Muharram
2 Safar
3 Rabi\u02bb I
  Rabi\u02bb II
  Jumada I
  Jumada II
  Rajab
  Sha\u02bbban
  Ramadan
  Shawwal
  Dhu\u02bbl-Qi\u02bbdah
  Dhu\u02bbl-Hijjah
like image 347
sajidbigler Avatar asked Oct 29 '22 11:10

sajidbigler


1 Answers

Take a look at Time4j library, calendar project.

Maven dependency:

<dependency>
    <groupId>net.time4j</groupId>
    <artifactId>time4j-calendar</artifactId>
    <version>4.24</version>
</dependency>

Example:

Stream.of(HijriMonth.values()).forEach(v->
            System.out.println("Display name: " + v.getDisplayName(Locale.US) + " month index: " + v.getValue()));

Output:

Display name: Muharram month index: 1
Display name: Safar month index: 2
Display name: Rabiʻ I month index: 3
Display name: Rabiʻ II month index: 4
Display name: Jumada I month index: 5
Display name: Jumada II month index: 6
Display name: Rajab month index: 7
Display name: Shaʻban month index: 8
Display name: Ramadan month index: 9
Display name: Shawwal month index: 10
Display name: Dhuʻl-Qiʻdah month index: 11
Display name: Dhuʻl-Hijjah month index: 12
like image 114
Enigo Avatar answered Nov 15 '22 04:11

Enigo