Java 8 – HijrahDate, How to calculate the Ramadan date

Java 8 – HijrahDate, How to calculate the Ramadan date

Ramadan is the 9th month of the Islamic calendar, the entire month.

1. HijrahDate -> Ramadan 2016

Full example to calculate the start and end of the Ramadan


import java.time.LocalDate;
import java.time.chrono.HijrahDate;
import java.time.temporal.ChronoField;
import java.time.temporal.TemporalAdjusters;

public class TestDate {

    public static void main(String[] args) {

        //first day of Ramadan, 9th month
        HijrahDate ramadan =
                .with(ChronoField.DAY_OF_MONTH, 1).with(ChronoField.MONTH_OF_YEAR, 9);
        System.out.println("HijrahDate : " + ramadan);

        //HijrahDate -> LocalDate
        System.out.println("\n--- Ramandan 2016 ---");
        System.out.println("Start : " + LocalDate.from(ramadan));

        //until the end of the month
        System.out.println("End : " + LocalDate.from(ramadan.with(TemporalAdjusters.lastDayOfMonth())));




HijrahDate : Hijrah-umalqura AH 1437-09-01

--- Ramandan 2016 ---
Start : 2016-06-06
End : 2016-07-05


  1. Wikipedia – Ramadan (calendar month)
  2. HijrahDate JavaDoc

Share this post

Comments (2)

  • Justin Reply

    Long time supporter, and thought I’d drop a comment.

    Your wordpress site is very sleek – hope you don’t mind me asking what theme you’re using?
    (and don’t mind if I steal it? :P)

    I just launched my site –also built in wordpress like yours– but the theme slows (!) the site down quite a bit.

    In case you have a minute, you can find it by searching for “royal cbd” on Google (would
    appreciate any feedback) – it’s still in the works.

    Keep up the good work– and hope you all take care of yourself during the coronavirus scare!

    March 29, 2020 at 9:56 am
  • AffiliateLabz Reply

    Great content! Super high-quality! Keep it up! 🙂

    February 25, 2020 at 12:10 am

Leave a Reply

Your email address will not be published. Required fields are marked *