cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert date format to Hijri date format

former_member229127
Participant
1,151

Hi All,

Can I know how can I change the date format to Hijri date format. For an example today's date is 2020-01-28 and I need to change to 3 Jumada II, 1441 AH (Hijiri Date) for today.

Regards,
Sandhya

View Entire Topic
MortenWittrock
Active Contributor
0 Kudos

Hi Sandhya

This is a very googleable question. One of the first hits is this Stack Overflow question. It seems there is support in the java.time package of Java 8 (which is what CPI is using), and the Joda-Time library has support as well.

Regards,

Morten

former_member229127
Participant
0 Kudos

Hi Morten,
I have already checked the code but am not getting the output.
Regards,
Sandhya

MortenWittrock
Active Contributor
0 Kudos

Hi sandhya.ravi

If you've tried some code already, post it and describe what's not working. Obviously, a code snippet from Stack Overflow (or anywhere else, for that matter) is not necessarily going to fit your exact problem, but might very well still point you in the right direction.

Regards,

Morten

former_member229127
Participant
0 Kudos

Hi Morten,

Yes I have tried to modify it from Stack Overflow where in the CPI in the libraries which are below is not accepting

import org.joda.time.chrono.IslamicChronology;
import org.joda.time.chrono.ISOChronology;


Code:

import com.sap.it.api.mapping.*;
import org.joda.time.Chronology;
import org.joda.time.LocalDate;
import org.joda.time.chrono.IslamicChronology;
import org.joda.time.chrono.ISOChronology;
def String customFunc(String todayHijri){
public class Test {
public static void main(String[] args) throws Exception {
Chronology iso = ISOChronology.getInstanceUTC();
Chronology hijri = IslamicChronology.getInstanceUTC(); LocalDate todayIso = new LocalDate(2013, 3, 31, iso);
LocalDate todayHijri = new LocalDate(todayIso.toDateTimeAtStartOfDay(),
hijri)
}
} return todayHijri
}

Regards,Sandhya

vijaysb15
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Sandhya,

I have a similar requirement in of the client projects. Could you please let me know if you were able to convert the date to Hijri format and also let us know what modifications helped to achieve it