获取java.time.chrono.HijrahDate实例的月份名称 [英] Get Month Name of java.time.chrono.HijrahDate instance
问题描述
HijrahDate hd=HijrahChronology.INSTANCE.date(LocalDate.of(2014,11, 25));
如果我们有 HijrahDate
实例,它是期望在 UmalquraCalendar API
中有一个显示月份名称的方法:
If we have HijrahDate
Instance , it is expected to have a method in UmalquraCalendar API
that shows the name of month :
我检查此实例的属性使用 groovy API :
i inspect properties of this instance using groovy API :
['era':AH,
'class':class java.time.chrono.HijrahDate,
'prolepticMonth':17233,
'eraValue':1,
'dayOfWeek':2,
'leapYear':false,
'chronology':Hijrah-umalqura,
'dayOfYear':32]
但是我们没有找到必须是以下列表项之一的月份名称:
However we don't find the month name which must be one of the following list items :
- Muḥarram(محرم意思是禁止),因为在这个月里战斗是
禁止(haram)。 Muharram包括
Ashura日。 - Ṣafar(صفر意为无效),据说是因为
异教阿拉伯房屋在一年中的这个时候是空的占用者
聚集食物。 -
Rabī'I(Rabī'al-Awwal,ربيعالأول)意为
第一春。
- Muḥarram (محرم meaning "forbidden"), so called because battle was forbidden (haram) during this month. Muharram includes the Day of Ashura.
- Ṣafar (صفر meaning "void"), supposedly named thus because pagan Arab houses were empty this time of year while their occupants gathered food.
Rabīʿ I (Rabīʿ al-Awwal, ربيع الأوّل) meaning "the first spring".
Rabī'II(Rabī'ath-Thānīربيعالثاني或Rabī'al-Ākhir
ربيعالآخ
Rabīʿ II (Rabīʿ ath-Thānī ربيع الثاني or Rabīʿ al-Ākhir ربيع الآخ
.....................
............等等 SEE
..................... ............ so on SEE
因此,由于没有属性保存月份的名称,因此有一个方法可以检索此信息吗?
Thus , since there is no attribute save month's name , it is expwcted to have a method retrieve this info ?
推荐答案
日期不包含有关月份或日期名称的信息。为此,您需要格式化程序:
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));
打印 Safar
。
这篇关于获取java.time.chrono.HijrahDate实例的月份名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!