How to get current date in time4j library?

219 Views Asked by At

how I can get current Persian Date with time4Jin java?

PersianCalendar jalali = new PersianCalendar();
2

There are 2 best solutions below

1
On BEST ANSWER

From the Javadoc of PersianCalendar:

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

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!