您能告诉我们如何以字符串格式解析阿拉伯语日期,如下图所示:
DateTimeFormatter.ofpattern("yyyy dd MMMM",locale).format(islamicDate));
现在以字符串格式获得阿拉伯语日期:
1437 06 Rajab
现在以字符串格式获得阿拉伯语日期:
如何将上面的字符串转换/解析为日期对象?
String xyz=DateTimeFormatter.ofpattern("yyyy dd MMMM",locale).format(islamicDate));
// now use xyz string to get hijiri date object
在星期四,2017年2月16日下午1:48 , Sajid Ahmed 写道:
public class HijriDate {
public static void main(String[] args) {
HijrahDate date1 = HijrahChronology.INSTANCE.dateNow();
System.out.println("HijrahDate date :: "+date1);
System.out.println("hijri to gregorian from sysdate :: "+IsoChronology.INSTANCE.date(date1).toString());
HijrahDate hd1 = HijrahChronology.INSTANCE.date(1438,04,18);
System.out.println("hijri to gregorian using islamic year month day ( 1 way ):: "+IsoChronology.INSTANCE.date(hd1));
System.out.println("hijri to gregorian using islamic year month day using localDate( 2 way ):: "+LocalDate.from(hd1));
Date date=new java.util.Date();
Calendar cl=Calendar.getInstance();
cl.setTime(date);
System.out.println("Normal gregorian Date1 :: "+date);
cl.add(Calendar.DATE,1);
HijrahDate islamyDate = HijrahChronology.INSTANCE.date(LocalDate.of(cl.get(Calendar.YEAR),cl.get(Calendar.MONTH)+1, cl.get(Calendar.DATE)));
System.out.println("gregorian to hijri one day plus :: " + islamyDate.toString());
//HijrahDate hd = HijrahChronology.INSTANCE.date(LocalDate.of(2017,01, 16));
System.out.println("format date MMMM :: "+DateTimeFormatter.ofPattern("MMMM").format(islamyDate));
System.out.println("format date MMMM dd-MMMM-yyyy :: "+DateTimeFormatter.ofPattern("dd-MMMM-yyyy").format(islamyDate));
//HijrahDate hd1 = HijrahChronology.INSTANCE.date(LocalDate.of(2017,01, 16));
//Locale locale = new Locale("ar","SA");
Locale locale = new Locale.Builder().setLanguageTag("ar-SA-u-nu-arab").build();
System.out.println("format dd-MMMM-yyyy :: "+DateTimeFormatter.ofPattern("dd-MMMM-yyyy", locale).format(islamyDate));
String dop = DateTimeFormatter.ofPattern("EEEE , dd MMMM ,yyyy", locale).format(islamyDate);
System.out.println("format 'EEEE , dd MMMM ,yyyy' with number format with out number format with locale :: "+dop);
}
}