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

前端 未结 3 1372
野趣味
野趣味 2021-01-12 08:25
HijrahDate hd=HijrahChronology.INSTANCE.date(LocalDate.of(2014,11, 25));

If we have HijrahDate Instance , it is expected to have a met

相关标签:
3条回答
  • 2021-01-12 08:43

    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.

    0 讨论(0)
  • 2021-01-12 08:49
    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

    0 讨论(0)
  • 2021-01-12 08:58

    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")));
    
    0 讨论(0)
提交回复
热议问题