cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert date format to Hijri date format

former_member229127
Participant
1,175

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

Accepted Solutions (0)

Answers (3)

Answers (3)

Sriprasadsbhat
Active Contributor
0 Kudos

Hello Sandhya,

You should import jar file. You will get joda related jar files freely(just google it).

Regards,

Sriprasad shivaram Bhqt

former_member229127
Participant
0 Kudos

Hi sriprasadshivaramabhat ,

I have added the Jar files and also the code for date transformation but still am getting issue. Jar file which I have added have share in the screen shot. As it is showing that code is having error.

Regards,

Sandhya

Sriprasadsbhat
Active Contributor
0 Kudos

Hello Sandhya,

Below blog from morten would help you.

https://blogs.sap.com/2017/01/23/how-to-use-external-java-libraries-in-hci/

In webui navigate to Resources and add your jar files.

Regards,

Sriprasad Shivaram Bhat

former_member229127
Participant
0 Kudos

Hi sriprasadshivaramabhat ,

Thanks a lot for your reply, but cant we directly input import org.joda.time.chrono.IslamicChronology &import org.joda.time.chrono.ISOChronology in web UI as I need to use in the mapping of SAP CPI. Already using jar file.

Regards,

Sandhya


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