如何在 time4j 库中获取当前日期?

How to get current date in time4j library?

如何使用 time4J 在 java 中获取当前的波斯语日期?

PersianCalendar jalali = new PersianCalendar();

我认为有多种方法可以这样做:

  1. nowInSystemTime()

    PersianCalendar jalali = PersianCalendar.nowInSystemTime();
    
  2. 使用转换

    PlainDate today = SystemClock.inLocalView().today();
    PersianCalendar jalali = today.transform(PersianCalendar.class);
    

希望对您有所帮助!

来自Javadoc of PersianCalendar

PlainDate today = SystemClock.inLocalView().today();
PersianCalendar jalali = today.transform(PersianCalendar.class);