Does Java support Julian calendar?

前端 未结 4 1553
不思量自难忘°
不思量自难忘° 2020-12-20 16:18

Oracle docs http://docs.oracle.com/javase/6/docs/technotes/guides/intl/calendar.doc.html states that Java supports 3 calendar systems: Gregorian, Japanese Imperial and Thai

相关标签:
4条回答
  • 2020-12-20 16:37

    The standard Calendar class might not, but the Joda Time library does.

    0 讨论(0)
  • 2020-12-20 16:38

    Yes but it's not in java.* :

    JulianCalendar javadoc

    0 讨论(0)
  • 2020-12-20 16:47

    Yes, it does.

    From the doc of GregorianCalendar:

    GregorianCalendar is a hybrid calendar that supports both the Julian and Gregorian calendar systems with the support of a single discontinuity, which corresponds by default to the Gregorian date when the Gregorian calendar was instituted (October 15, 1582 in some countries, later in others). The cutover date may be changed by the caller by calling setGregorianChange().

    Use setGregorianChange to change it.

    public void setGregorianChange(Date date) Sets the GregorianCalendar change date. This is the point when the switch from Julian dates to Gregorian dates occurred. Default is October 15, 1582 (Gregorian). Previous to this, dates will be in the Julian calendar. To obtain a pure Julian calendar, set the change date to Date(Long.MAX_VALUE). To obtain a pure Gregorian calendar, set the change date to Date(Long.MIN_VALUE).

    0 讨论(0)
  • 2020-12-20 16:58

    People don't use java.util.Calendar a lot. In fact, it will be succeeded soon by what is now already in a library called 'joda time', when JSR-310 finishes. Joda Time also has a Julian calendar.

    Just add joda-time to your project as a dependency and away you go.

    0 讨论(0)
提交回复
热议问题