Java 8 – HijrahDate, How to calculate the Ramadan date - LearnHowToCode SarkariResult.com Interview Questions and Answers LearnHowToCodeOnline
Java 8 – HijrahDate

Java 8 – HijrahDate, How to calculate the Ramadan date

HijrahDate  Ramadan 2017

Full example to calculate the start and end of the Ramadan 2017
TestHijrahDate.java
package com.mycareerrepublic.date;

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 = HijrahDate.now()
.with(ChronoField.DAY_OF_MONTH, 1).with(ChronoField.MONTH_OF_YEAR, 9);
System.out.println("HijrahDate : " + ramadan);

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

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

}

}
Output
HijrahDate : Hijrah-umalqura AH 1437-09-01

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

About Mariano

I'm Ethan Mariano a software engineer by profession and reader/writter by passion.I have good understanding and knowledge of AngularJS, Database, javascript, web development, digital marketing and exploring other technologies related to Software development.

0 comments:

Featured post

Political Full Forms List

Acronym Full Form MLA Member of Legislative Assembly RSS Really Simple Syndication, Rashtriya Swayamsevak Sangh UNESCO United Nations E...

Powered by Blogger.