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

时间:2018-05-21 08:48:39

标签: java time4j

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

PersianCalendar jalali = new PersianCalendar();

2 个答案:

答案 0 :(得分:1)

我认为有多种方法可以做到这一点:

  1. nowInSystemTime()

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

    PlainDate today = SystemClock.inLocalView().today();
    PersianCalendar jalali = today.transform(PersianCalendar.class);
    
  3. 希望它有所帮助!

答案 1 :(得分:0)

来自Javadoc of PersianCalendar

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