On 08/15/19 02:58, Yonatan Misgan wrote: > From this source code how can I get only the year to convert my own > calendar year. I need this because Ethiopian calendar is totally differ > from GC in terms of day, month and year.
I find myself wondering whether getting only the year is sufficient to do the conversion. There is already an Ethiopic calendar available for Java (not included, but in org.threeten.extra[1]), and it seems to say the years do not align precisely with Gregorian years (as I would not have expected anyway): "Dates are aligned such that 0001-01-01 (Ethiopic) is 0008-08-27 (ISO)." So it seems more likely that you would need a calculation involving the year, month, and day ... or even that the Julian day number already stored in PostgreSQL could be the most convenient starting point for the arithmetic you need. It's possible you might want to crib some of the algorithm from the threeten-extra Ethiopic date sources [2]. It would need adjustment for the PostgreSQL epoch being Gregorian year 2000 rather than Java's 1970 (a simple constant offset), and for PostgreSQL using a Julian day number rather than java.time's proleptic Gregorian (a difference changing by three days every 400 years). Another option would be to take advantage of PL/Java and directly use the threeten-extra Ethiopic calendar. Regards, -Chap [1] https://www.threeten.org/threeten-extra/apidocs/org.threeten.extra/org/threeten/extra/chrono/EthiopicDate.html [2] https://github.com/ThreeTen/threeten-extra/blob/master/src/main/java/org/threeten/extra/chrono/EthiopicDate.java