I have a date in the Gregorian calendar and want to look up the same day in the Julian calendar.
This should be easy with the Date/Time API of Java 8 but I couldn't find a way to do it. The code should look something like this:
/*
* LocalDate uses the Gregorian calendar
*/
LocalDate date = LocalDate.parse("2017-10-29");
/*
* switch from Gregorian calendar to Julian calendar here
*/
;
/*
* output should be 2017-10-16
*/
System.out.println(date);
You can try it out online here
Edit
This is certainly no duplicate of Convert from Gregorian to Julian calendar. My question asks specifically about the Java Data/Time API.
The Julian chronology is not built into Java 8 or 9. Instead, the ThreeTen-Extra project has JulianChronology
and JulianDate
classes. Using it is simple.
JulianDate jd = JulianDate.from(localIsoDate);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With