Get Month Name of java.time.chrono.HijrahDate instance

巧了我就是萌 提交于 2019-12-01 06:33:13

The date does not contain information about the names of the months or days. To get that you need a formatter:

System.out.println(DateTimeFormatter.ofPattern("MMMM").format(hd));

prints Safar.

Since the main language of UmalQura is the arabic langugage, Developers & programmers who uses UmalQuraCalender want to display the month in arabic. Thus , we base on @assylias answer we can add the Locale object to print صفر instead of Safar

System.out.println(DateTimeFormatter.ofPattern("MMMM").format(hd,new Locale("ar")));
public String getIslamicDate(){
    return  DateTimeFormatter.ofPattern("MMMM",new Locale("ar")).format(HijrahDate.now());
}

I think this should work just fine and return the month in arabic language

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!