简体   繁体   中英

How to get current date in time4j library?

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

PersianCalendar jalali = new PersianCalendar();

From the Javadoc of PersianCalendar :

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

I think there are multiple ways to do so:

  1. nowInSystemTime()

     PersianCalendar jalali = PersianCalendar.nowInSystemTime(); 
  2. using transformation

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

Hope it helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM